CPU benchmarking
It's rather hard to find a CPU benchmark that is more representative of database performance more useful than 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; depends on the amount of RAM in your server:
\timing CREATE TABLE test (id INTEGER PRIMARY KEY); INSERT INTO test VALUES (generate series(1,100000)); EXPLAIN ANALYZE SELECT COUNT(*) FROM test;
Both the insertion time and how long it takes to count each value are interesting...