CPU benchmarking

It's rather hard to find a CPU benchmark that is more representative of database performance more easily than by just using a database to do something processor-intensive. You can easily build some quick, PostgreSQL-oriented CPU tests using the database psql client and its \timing feature, which shows you how long each statement takes to run. Here's an example that just exercises the CPU and memory, by adding the first million integers together with the always handy generate_series set returning function:

\timing 
SELECT sum(generate_series) FROM generate_series(1,1000000); 

Here's another more complicated example that may use some disk accesses too, in addition to stressing CPU/memory; it depends on the amount of RAM in your ...

Get PostgreSQL 10 High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.