Re: Wrong index used when ORDER BY LIMIT 1

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Wrong index used when ORDER BY LIMIT 1
Дата
Msg-id 15421.1135193659@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Wrong index used when ORDER BY LIMIT 1  (Szűcs Gábor <surrano@gmail.com>)
Ответы Re: Wrong index used when ORDER BY LIMIT 1  (Szűcs Gábor <surrano@gmail.com>)
Список pgsql-performance
=?ISO-8859-2?Q?Sz=FBcs_G=E1bor?= <surrano@gmail.com> writes:
> Query is:
> SELECT idopont WHERE muvelet = x ORDER BY idopont LIMIT 1.

Much the best solution for this would be to have an index on
    (muvelet, idopont)
--- perhaps you can reorder the columns of "muvelet_vonalkod_muvelet"
instead of making a whole new index --- and then say

    SELECT idopont WHERE muvelet = x ORDER BY muvelet, idopont LIMIT 1

PG 8.1 can apply such an index to your original query, but older
versions will need the help of the modified ORDER BY to recognize
that the index is usable.

            regards, tom lane

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

Предыдущее
От: Michael Fuhr
Дата:
Сообщение: Re: Wrong index used when ORDER BY LIMIT 1
Следующее
От: Tom Lane
Дата:
Сообщение: Re: ORDER BY costs