Re: Query problem fixed
От | Tom Lane |
---|---|
Тема | Re: Query problem fixed |
Дата | |
Msg-id | 17680.1054219783@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Query problem fixed ("Kevin Schroeder" <mirage@mirageworks.com>) |
Список | pgsql-performance |
"Kevin Schroeder" <mirage@mirageworks.com> writes: > select row_key, column1, column2, column3, column4, column5 from table1 > where column6 = 1 order by column3 desc limit 21; > I changed the index to > message_index btree (column3, column6) > rather than > message_index btree (column6, column3, column7) That's probably not the best solution. It would be better to leave the index with column6 first and write the query as ... where column6 = 1 order by column6 desc, column3 desc limit 21 This doesn't change the results (since there's only one value of column6 in the output), but it does cause the planner to realize that a backwards scan of the index would produce what you want with no sort step. The results should be essentially instantaneous if you can get the query plan down to Index Scan Backward + Limit. regards, tom lane
В списке pgsql-performance по дате отправления: