Re: PostgreSQL 8.3.3 chooses wrong query plan when LIMIT 1 added?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: PostgreSQL 8.3.3 chooses wrong query plan when LIMIT 1 added?
Дата
Msg-id 26354.1225148263@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: PostgreSQL 8.3.3 chooses wrong query plan when LIMIT 1 added?  (Mark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>)
Список pgsql-general
Mark Cave-Ayland <mark.cave-ayland@siriusit.co.uk> writes:
> svnlog=# SELECT revision_id FROM revision_files WHERE file_id=(SELECT
> file_id
> FROM files WHERE filepath='/trunk/app/widgets/gimptoolbox-dnd.c' LIMIT 1)
> ORDER BY revision_id DESC LIMIT 1;
>   revision_id
> -------------
>         15011
> (1 row)

> Time: 935.816 ms

Hmm, I'd expect it to be more or less instantaneous given the right
index.  What does EXPLAIN ANALYZE say about this?

> However, some more searching came up with this "ORDER BY x + 0"
> variation which seems to consistently perform the fastest for varying
> flavours of revision_id by forcing use of the file_id index:

And that?

            regards, tom lane

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Postgres optimizer choosing wrong index
Следующее
От: "Scott Marlowe"
Дата:
Сообщение: Re: How Do I Find the Date When A Table Was Last Changed?