Sep 3, 2020

Slow Postgres?

Well, not completely. But I encountered a problem which I find interesting. A query is performed that return 0 rows. The query performs an index scan to find this out. Now, if the query tries to return all the rows from the table it is really slow. If it only returns a few rows (some that might not even be part of the index I believe), the query becomes around 400 times faster. In my imagination I would have expected that since no rows are returned it wouldn't matter which columns we want to return or not.