Which is faster? PostgreSQL or SQL Server?
Well we can figure this out by running similar queries & workloads on a database with the same structure and data on both PostgreSQL & SQL Server.
For this purpose, I love StackOverflow2013 database copy. Neither too large, nor too small.
For SQL Server, you can download this database from BrentOzar’s blog post How to Download the Stack Overflow Database. This restores a 50 GB database on SQL Server.
Direct link to download a 10 GB zipped file of StackOverflow2013 from Brent’s website.
For PostgreSQL, you can download a plain-text compressed pg_dump backup of 8 GB from this link. This has a similar structure and the same data as the SQL Server copy. When restored, it is supposed to consume approximately 28 GB in PostgreSQL.
Assuming, downloaded file path /tmp/backups/stackoverflow2013.sql.gz. We can extract the compressed backup file, and restore data from it inside PostgreSQL using the following sample code –
1 2 3 4 5 6 7 8 9 10 11 |
# Unzip backup file & restore database cd /tmp/backups/ gunzip -k stackoverflow2013.sql.gz psql> -- create database (inside postgresq) create database stackoverflow2013; -- import from backup file (psql command) \i /tmp/backups/stackoverflow2013.sql |
Below is the row count of tables with stackoverflow2013 database on PostgreSQL –

I hope this will be helpful to all database enthusiasts out there trying to learn PostgreSQL & SQL Server.