How to calculate A * B mod N, where numbers are 64 bit integers

I made a program to calculate ‘A * B mod N’, where A, B and N are 64 bit integers.

Main problem is to avoid overflow when calculate ‘A * B’.

I searched a while and finally decided to use the interleaved modular multiplication method, which is used in the feild of electric circuit design.

I found some bugs when I tested corner cases, so I have to fix them [2018.9.2]. I think I’ve fixed them [2018.9.3]. I’ve just improved it! [2018.9.5]

The program is shown below:

Citus with multi-coordinator using Streaming Replication

In the standard setup of Citus, it has one coordinator, so it is the single point of failure and the bottle neck of the system.

To solve these disadvantages, I built a multi-coordinator using Streaming Replication, which is the built-in replication feature of PostgreSQL.

postgres cluster management system in GoCardless

I found an interesting postgres cluster management system using Pacemaker. It is created by GoCardless. They provide a vagrant box, so we can play and learn it easily.

When should I do VACUUM FULL?

There is unfortunately no best practice when you should execute “VACUUM FULL”. The extension pg_freespacemap however gives you suggestion.

Customized Statistics Views in PostgreSQL

I always use my customized statistics views shown below because the original ones provide only minimum information.

I show my tools in this post.

Difference between PostgreSQL and MySQL: (1) Replication

Many people around the world admire the Uber’s article “Why Uber Engineering Switched from Postgres to MySQL”, but I think this article contains many mistakes. So, I’m going to provide correct information regarding to PostgreSQL and MySQL.

In this post, I explain the replication of both databases.

Testing PostgresPro's pg_arman with ptrack

In this week end, I tested PostgresPro’s pg_arman with ptrack. Speaking from the conclusion, it works well.

Citus with BRIN index

In this weekend, I tried Citus. The latest version of Citus is for PostgreSQL 9.5, so it can be used BRIN index.

Multi-GTM for Postgres XC

Five years ago, I was interested in Postgres-XC , currenty called Postgres-X2, and made a multi-GTM (global transaction manager) system for it.

Though I had forgotten this work for a long time, I found its executable files from my old PC a month ago (unfortunately the source code of them was lost). They perfectly run, so I provide a Vagrant box to run my old program on your PC.

How to relocate tablespace directory

I’ll demonstrate how to relocate a tablespace directory without the reconstruction of databases.