3 ms·
This is not a pg specific thing, for instance in SQL Server this is referred to as “spilling to disk”. Large sorts can spill to disk, and the query planner may
by dspillett 5y ago
This is not a pg specific thing, for instance in SQL Server this is referred to as “spilling to disk”. Large sorts can spill to disk, and the query planner may assume this is going to be done in RAM, based on what stats it has about the relevant indexes, but later have to spill to disk, so pick a plan that is sub-optimal.
- b112 5y agoSome queries with mysql result in temp tables, and some use disk based tables, due to complexity. https://dev.mysql.com/doc/refman/8.0/en/internal-temporary-tables.html https://dev.mysql.com/doc/refman/8.0/en/internal-temporary-t...
- scottlamb 5y agoEven SQLite3 does this. https://www.sqlite.org/queryplanner.html https://www.sqlite.org/queryplanner.html says under "Sorting": > Furthermore, the entire output is accumulated in temporary storage (which might be either in main memory or on disk, depending on various compile-time and run-time settings) which can mean that a lot of temporary storage is required to complete the query. It also will sometimes create an index during a query. https://www.sqlite.org/tempfiles.html https://www.sqlite.org/tempfiles.html mentions this under "Transient Indices".