PostgreSQL benchmarks
An important question regarding a database system is: how fast is it? How many transactions can it handle per second, or how much time a particular query takes to execute? The topic on the performance of a database has been covered in Chapter 10, Optimizing Database Performance. Here, we will only discuss the task of measuring it.
The Psql meta-command \timing
is used to measure the time of execution of a particular SQL command. Once timing is enabled, psql shows the time of execution for each command:
car_portal-# \timing Timing is on. car_portal=# SELECT count(*) FROM car_portal_app.car; count ------- 229 (1 row) Time: 19.492 ms
Usually, that is enough to understand which query is faster. However, one cannot rely on that timing when it comes to estimating the number requests the server can handle per second. This is because the time for a single query depends on many random factors: the current load of the server, the state of the cache, and so on.
PostgreSQL provides...