Postgres 18 Skip Scan Turns 393 Ms Into 2.4 Ms for One Column Order Only

https://hackernoon.imgix.net/images/RxIFGDejXQUaj54NhArKLyi3a272-1a1f95ec392.png

Slow Postgres, part 4 of 8.

On PostgreSQL 17.7, the planner ignored an index on (status, created_at) for one day of orders and read all ten million rows, 393 ms. On 18.7 the same index answers it in 2.4 ms with B-tree skip scan. The other order got no rescue. Counting pending orders through (created_at, status) still reads the whole table on 18, 295 ms against 6.6 with the columns swapped.

Five queries against both column orders on PostgreSQL 18

The short version:

  • Equality columns go first and the range column last, on 17 and 18 alike: for the same 4,031 failed orders of one week, (status, created_at) read 19 index pages and (created_at, status) 787.
  • Skip scan lets 18 use an index with no condition on its first column, searching it about once per value of that column: four statuses, seven searches, 2.4 ms.
  • The planner counts on skipping...

Copyright of this story solely belongs to hackernoon.com. To see the full text click HERE

Read more

https://www.reuters.com/resizer/v2/UD245BZEEBNEXAGTOXAEHHBFEE.jpg?auth=d9331832fad370bc44d11d20138290b58e599198bd2b827cf4e83034c6d9b508&height=1005&width=1920&quality=80&smart=true

OpenAI and SpaceX reach an agreement to bring OpenAI models to Grok Build, formerly Cursor; OpenAI said in August it planned to stop providing models to Cursor

Featured Podcasts Big Technology Podcast: Jensen Huang Goes To Washington — With Josh Rogin The Big Technology Podcast takes you behind the scenes in the tech world featuring interviews with plugged-in insiders and outside agitators. Subscribe to Big Technology Podcast. Great Chat: Nothing ever happens A podcast mostly about tech. Brought