The prescription of changing sequential_page_cost to equal random_page_cost is certainly reasonable for SSD, but I wonder if the underlying issues aren't somewhat deeper and more interesting. One difference between a sequential scan and an index scan is the amount of data being scanned. PostgreSQL stores information horizontally as rows and a sequential scan will have to read in all column values of all rows. An inde…
How a single PostgreSQL config change improved slow query performance by 50x
11–20 of 46 posts
Re: How a single PostgreSQL config change improved slow query performance by 50x
#12Thanks for the tip. This probably affects more people than there are people who realize it. It would be really interesting if PG would use machine learning to discover this sort of tuning on its own.
+1 for the idea of tuning query optimization based on ML. I don't know of any DBMSs that take this advice, and that's remarkable in this day and age.
https://docs.microsoft.com/en-us/sql/relational-databases/au...
Re: How a single PostgreSQL config change improved slow query performance by 50x
#13In my case I increased STATISTICS to 5000 and the planner immediately start using the index instead of full table scan.
https://blog.pgaddict.com/posts/common-issues-with-planner-s...
Re: How a single PostgreSQL config change improved slow query performance by 50x
#14Thanks for the tip. This probably affects more people than there are people who realize it. It would be really interesting if PG would use machine learning to discover this sort of tuning on its own.
Your suggestion sounds very much like that of a Silicon Valley start-up guy ("Machine Learning to the rescue!") but I believe here a deterministic detection of the underlying drive, possibly tied to a warning on start-up, would be easier to code, less bug-prone, and faster. OTOH, if you speak about the general problem of optimizing configuration, then I distinctly recall having read something about automatic server c…
IIRC it was an academic paper and the process was somewhat byzantine when I tried to recreate it. But the results looked good.
Re: How a single PostgreSQL config change improved slow query performance by 50x
#15Thanks for the tip. This probably affects more people than there are people who realize it. It would be really interesting if PG would use machine learning to discover this sort of tuning on its own.
+1 for the idea of tuning query optimization based on ML. I don't know of any DBMSs that take this advice, and that's remarkable in this day and age.
The authors propose a way to do some automatic tuning for MySQL and Postgres.
Link to the paper itself: http://db.cs.cmu.edu/papers/2017/tuning-sigmod2017.pdf
Re: How a single PostgreSQL config change improved slow query performance by 50x
#16Thanks for the tip. This probably affects more people than there are people who realize it. It would be really interesting if PG would use machine learning to discover this sort of tuning on its own.
Your suggestion sounds very much like that of a Silicon Valley start-up guy ("Machine Learning to the rescue!") but I believe here a deterministic detection of the underlying drive, possibly tied to a warning on start-up, would be easier to code, less bug-prone, and faster. OTOH, if you speak about the general problem of optimizing configuration, then I distinctly recall having read something about automatic server c…
Re: How a single PostgreSQL config change improved slow query performance by 50x
#17Thanks for the tip. This probably affects more people than there are people who realize it. It would be really interesting if PG would use machine learning to discover this sort of tuning on its own.
+1 for the idea of tuning query optimization based on ML. I don't know of any DBMSs that take this advice, and that's remarkable in this day and age.
Clarification: this is for planning how to execute a query, not for tuning the db settings
Re: How a single PostgreSQL config change improved slow query performance by 50x
#18I always increase the seq scan cost, but another thing that helped me more was updating the table statistics. In that way you can make the planner better aware of your indexes. In my case I increased STATISTICS to 5000 and the planner immediately start using the index instead of full table scan. https://blog.pgaddict.com/posts/common-issues-with-planner-s...
Re: How a single PostgreSQL config change improved slow query performance by 50x
#19The prescription of changing sequential_page_cost to equal random_page_cost is certainly reasonable for SSD, but I wonder if the underlying issues aren't somewhat deeper and more interesting. One difference between a sequential scan and an index scan is the amount of data being scanned. PostgreSQL stores information horizontally as rows and a sequential scan will have to read in all column values of all rows. An inde…
You're saying that during sequential scans, the time it takes per row is O(n) where n is the number of columns? I find that hard to believe. Can anyone confirm / deny this?
But yes, tables with more columns normally take more time to scan sequentially. The complete tuple is always loaded (excluding the data of TOAST [2] attributes), there is no way to only load one column. This is one of the reasons that column-oriented databases can be faster than row-oriented databases [3].
[1] https://www.postgresql.org/message-id/42C3C382.5020108@cinec... [2] https://www.postgresql.org/docs/9.5/static/storage-toast.htm... [3] https://en.wikipedia.org/wiki/Column-oriented_DBMS
Re: How a single PostgreSQL config change improved slow query performance by 50x
#20The prescription of changing sequential_page_cost to equal random_page_cost is certainly reasonable for SSD, but I wonder if the underlying issues aren't somewhat deeper and more interesting. One difference between a sequential scan and an index scan is the amount of data being scanned. PostgreSQL stores information horizontally as rows and a sequential scan will have to read in all column values of all rows. An inde…
You're saying that during sequential scans, the time it takes per row is O(n) where n is the number of columns? I find that hard to believe. Can anyone confirm / deny this?