logoalt Hacker News

skybriantoday at 12:24 AM1 replyview on HN

Databases often use table statistics to try to do better at generating query plans. I wonder if they use them to make indexes faster as well?


Replies

10000truthstoday at 1:18 AM

The cost plan is a crude approximation of the actual query cost. Sometimes, the query planner makes a terrible guess. Your resident DBA won't appreciate being sometimes paged at 3 AM on a Sunday. A good strategy is to freeze the query plan once you have sufficient sample size of data in the involved tables.