Postgresql – Comparing Query Performance Across DBMSs

mariadbpostgresqlqueryquery-performancesqlite

I have a list of queries that I want to compare the execution time of across 3 different DBMSs: SQLite, MariaDB and postgreSQL.

I have been looking into command line tools for each system to get the query execution time.

  • For SQLite I used the .timer ON command to show the real/user/sys time after each query
  • For MariaDB I set the profiling and called "show profiling" to get the duration of each query
  • For PostgreSQL I executed the query with "analyze" to show the full query plan including execution time.

My problem is that I wasn't able to find documentation for these tools that specified what the time actually is: CPU vs actual time etc, and some of the values are very different. For example, a join query that I tried with MariaDB took 33 mins but with postgreSQL it only took a few seconds.

Does anyone have insight into how these metrics are actually measuring query time, and if they can accurately be compared with each other? Alternatively, is there a better tool I should be using for this task? Any help is appreciated.

Best Answer

I think that you shouldn't rely on any of that. The only real measure is how long the query actually took, when measured from the client side. That also avoids overhead during query execution that you get if you for example use EXPLAIN (ANALYZE) in PostgreSQL.

So I would do it like this:

  • measure the current time on the client

  • send a query to the server

  • wait until execution is complete and the client has got the result

  • measure the time again and calculate the difference