Compiling and Installing PostgreSQL
Build the PostgreSQL database from the source code.
- Download the PostgreSQL 11.3 source package postgresql-11.3.tar.gz.
For the download URL, see Environment Requirements.
- Upload the source package to the /home directory on the server, go to the /home directory, and decompress the source package.
1 2
cd /home tar -xvf postgresql-11.3.tar.gz

- Go to the decompressed PostgreSQL directory and compile PostgreSQL.
1 2
cd /home/postgresql-11.3 ./configure -prefix=/usr/local/pgsql

- Configure performance tuning options.
- Open the Makefile.global file.
1vim /home/postgresql-11.3/src/Makefile.global - Press i to enter the insert mode and add the following content to the end of line 261 to enable LSE performance optimization:
-march=armv8-a+crc+lse
The target file content:

- Press Esc, type :wq!, and press Enter to save the file and exit.
- Open the Makefile.global file.
- Install PostgreSQL.
1make -j 64

1make -j 64 install

In the command, -j 64 can make full use of the multi-core feature of the CPUs to accelerate the compilation. The number following -j indicates the number of CPU cores. You can run the cat /proc/cpuinfo | grep processor | wc -l command to query the number of CPU cores. The value specified must be less than or equal to the actual number of CPU cores.
- View the PostgreSQL installation directory.
1ls /usr/local/pgsql - View the PostgreSQL version.
1/usr/local/pgsql/bin/postgres --version
Parent topic: Porting Guide