Forcing index usage
От | Jonathan Marks |
---|---|
Тема | Forcing index usage |
Дата | |
Msg-id | 679378F9-E085-4FE3-BC78-3073A4B86438@gmail.com обсуждение исходный текст |
Ответы |
Re: Forcing index usage
Re: Forcing index usage |
Список | pgsql-general |
Hi folks — We’ve got several tables that are relatively large (~250-500GB in total size) that use very large (tens to hundreds of GB)GIN indexes for full-text search. We’ve set the column statistics for our tsvector columns as high as they go (10,000).We almost always order our search results by a separate date column (which has an index) and we almost always usea limit. Whenever the query planner chooses to use the indexes, queries on these tables are somewhat fast, maxing out at a few hundredmilliseconds per query (which is terrible, but acceptable to end users). When the query planner chooses not to use the indexes, queries can take many tens of seconds if they ever finish at all.When this happens, the query planner usually chooses to use the date index instead of the GIN index, and that is almostalways a bad idea. We have sometimes been able to trick it into a better query plan by also adding the tsvector columnin the ORDER BY clause, but that has bad performance implications if the result set is large. Is there a way to tell Postgres “please don’t use index X when queries that could use index Y instead occur?” Thank you!
В списке pgsql-general по дате отправления: