Re: Question on Explain : Index Scan

Поиск
Список
Период
Сортировка
От DM
Тема Re: Question on Explain : Index Scan
Дата
Msg-id AANLkTinCPyy5reWELSJX3YRZPwFH_hgA8_YNcAOkxyv9@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Question on Explain : Index Scan  (Mathieu De Zutter <mathieu@dezutter.org>)
Ответы Re: Question on Explain : Index Scan  (DM <dm.aeqa@gmail.com>)
Список pgsql-general
perfecto, thank you for the explanation.

- Deepak

On Thu, Oct 21, 2010 at 3:20 AM, Mathieu De Zutter <mathieu@dezutter.org> wrote:
On Thu, Oct 21, 2010 at 3:47 AM, DM <dm.aeqa@gmail.com> wrote:
> I was hoping the optimizer would do a join using index scan.
>
> Could some one please explain me why its not doing an index scan rather than
> sequential scan .


A index scan would be probably slower here because you're asking for a
lot of rows. A lot of rows means a lot of I/O, and an index scan is
more I/O intensive (since it has to read the index too). If you limit
the result (by being more selective in your where clause, just like
you do in the first two queries), postgres will most likely switch to
index scan.

You can see for yourself if index-scan would be faster in your case by
running the following command before "explain (analyze)":

set enable_seqscan = off;

BTW, try to use explain analyze instead of explain, that way you'll
see the actual timings too instead of just the planner estimates.

Kind regards,
Mathieu

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

Предыдущее
От: "Reid Thompson"
Дата:
Сообщение: Re: Cannot Start Postgres After System Boot
Следующее
От: Scott Marlowe
Дата:
Сообщение: Re: Cannot Start Postgres After System Boot