Re: Why LIMIT after scanning the table?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Why LIMIT after scanning the table?
Дата
Msg-id 21975.1051712545@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Why LIMIT after scanning the table?  ("Jim C. Nasby" <jim@nasby.net>)
Список pgsql-performance
"Jim C. Nasby" <jim@nasby.net> writes:
> explain select count(*)
>     FROM (SELECT * FROM email_rank WHERE project_id = :ProjectID LIMIT 100) AS t1;

> The idea is that the inner-most query would only read the first 100 rows
> it finds, then stop. Instead, if explain is to be believed (and speed
> testing seems to indicate it's accurate), we'll read the entire table,
> *then* pick the first 100 rows. Why is that?

You're misreading the EXPLAIN output.  Try EXPLAIN ANALYZE to see how
many rows really get fetched.

            regards, tom lane


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

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: Why LIMIT after scanning the table?
Следующее
От: "Peter Darley"
Дата:
Сообщение: Query Plan far worse in 7.3.2 than 7.2.1