Benchmark results of PostgreSQL on Raspberry PI

In step 5, we have installed PostgreSQL. We then performed some benchmarks, by following tips and tricks contained in the world famous book about “PostgreSQL High Performance” by our dear Gregory Smith.

Results will be now presented, to test the efficiency of a PostgreSQL database server installed on a Raspberry PI. This represents a good challenge: build up a database server in a cheap way! Let’s not forget our goal: be able to adopt Postgres in schools so that the SQL language can be taught!

Obviously performances of a good server with a multicore CPU, having more than 32GB RAM and supported by one of the latest high performance storage units cannot be reached in our example. Anyway, we’ll show how some typical database servers operations can be reproduced in reduced scale also in a Raspberry PI with PostgreSQL.

Server specifics

To better understand the results, we need to know the hardware configuration at our disposal:

  • CPU: ARMv6-compatible processor rev 7 (v6l), 700MHz, single core
  • RAM: 512MB
  • SD card speed class 10 (30MB/s)
  • Operating system: Raspbian (Debian wheezy 7.0)
  • PostgreSQL version: 9.2 (the one used at the time of the benchmark)

Useful tools used for the benchmark

The benchmark foresees the measurement of I/O rate of the storage device, filesystem speed and database transactions rate. This last was checked using the pgbench tool. Pgbench submits queries as test and measures transactions rate for different DML commands and client configurations and which was yet installed with PostgreSQL.

For the benchmark of the storage unit and of the operative system we used the bonnie++ tool. On Raspbian can be easily installed such as in a Debian distribution.

The access rate of memory streams, known also as “stream scaling”, has been tested using a bash script and C libraries[1] developed by the department of computer science of the University of Virginia and published in their web page.

Benchmarks were executed tweaking operative system settings[2], like read-ahead and file system, to test performances and find the best system configuration. For this purpose, we used the fabric library creating Python scripts to be launched from remote hosts.

SD card read speed

This benchmark is made measuring the “zcav” that is the measurement of read speed as a function of the data position in the read device. This is possible with the zcav tool, installed by default with the bonnie++ package.

zcav benchmarck result

Above picture summarizes the obtained results for the SD card zcav: constant behaviour is expected being a digital device and not a disk. More interesting the found speed value: 22.5 MB/s, to be compared with what producer declared (30 MB/s).

IO rate and filesystem speed

With bonnie++ we have measured the sequential W/R speeds and seek rates, varying filesystem (xfs, ext4) and read-ahead (4096, 8192, 16384).

bonnie sequential write
Sequential write speed measured by bonnie++

bonnie sequential read
Sequential read speed measured by bonnie++

bonnie seek rate
Seek rate measured by bonnie++

The filesystem with the highest performances resulted the ext4 (sequential read in this case reach more than 26 MB/s). Best configuration includes also 4096 as read-ahead value, although performances did not seem to change modifying this parameter.

Stream scaling

Usually, once the best configuration is set, stream scaling is measured varying the concurrency by the bash script mentioned above. In the Raspberry PI case, this can be made only referring to the CPU single core. The results of the benchmark showed a CPU access to memory speed equal to 282 MB/s, which is not a bad result considering that Raspberry PI has 512MB RAM.

PostgreSQL performances on Raspberry PI

This benchmark consists of two tests:

  • creating a small size database (155MB of data), able to be contained totally in RAM
  • creating a large size database (1920MB of data), about four time the size of available RAM (to be sure that it will not be totally contained only in RAM)

For each database, INSERT SELECT and TPC-B like test[3] are executed, measuring the commit rate. Moreover, multi-client commits can be checked using pgbench launching it from a remote multi-core machine (we used a quad-core CPU with enabled hyperthread, so a total of 8 clients can be reached).

The following tables summarize the obtained results:

small size database benchmark results

DML sentences tps
INSERT (single client) 22
INSERT (multi client) 33
SELECT (multi client) 412
TPC-B 14

large size database benchmark results

DML sentences tps
SELECT (multi client) 197
TPC-B 10

We could not reach performances of a real server, anyway just with a raspberry PI we were able to do typical database server operation, multiclient connections included!

footnotes
[1] Be sure gcc compiler is installed: apt-get install gcc.
[2] Concurrency could not be changed because of the single core Raspberry PI CPU.
[3] see www.tpc.org/tpcb/‎

Raspberry PI has 512MB RAM

3 thoughts on “Benchmark results of PostgreSQL on Raspberry PI

    • Hi Stelia,

      Funny that you’ve asked that! We are already preparing a benchmark comparing the Raspberry Pi 1 and 2. Stay tuned because after we finish the tests, a new article is coming up for sure. Have you already read the article of Rubens about PostgreSQL installation on a Raspberry Pi 2? Do it if not!

Leave a Reply to Carlo Garcia Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>