Re: Forcing index usage

Поиск
Список
Период
Сортировка
От Jeff Janes
Тема Re: Forcing index usage
Дата
Msg-id CAMkU=1z5aDi6ujzDFWk4DhUdz6BJD9pKMkUFh+i24q+wkTnqCw@mail.gmail.com
обсуждение исходный текст
Ответ на Forcing index usage  (Jonathan Marks <jonathanaverymarks@gmail.com>)
Список pgsql-general
On Wed, Apr 3, 2019 at 12:13 PM Jonathan Marks <jonathanaverymarks@gmail.com> wrote:

Is there a way to tell Postgres “please don’t use index X when queries that could use index Y instead occur?”

Late to the party here, but...

Not directly.  I've had luck in changing the procost of functions (or the functions which back the operators) which are frequently executed in the slower plan, but not frequently executed in the faster plan.  For example, walking the time index executing @@ on each row until it finds enough is probably going to involve a lot more @@ than using the full text index and invoking @@ only on the recheck rows.  The cost of @@ (via "ts_match_vq") is probably way too low, especially if it has to fish an argument out of TOAST.

If that doesn't work, you can just change the query to prevent the bad index from being used.

For example, PostgreSQL is not currently smart enough to use an index on "mtime" to support the ordering of a query that is written as:

ORDER BY mtime + interval '0 seconds'

Cheers,

Jeff

В списке pgsql-general по дате отправления:

Предыдущее
От: Joe Conway
Дата:
Сообщение: Re: how to add more than 1600 columns in a table?
Следующее
От: pabloa98
Дата:
Сообщение: Re: how to add more than 1600 columns in a table?