Re: Have: Seq Scan - Want: Index Scan - what am I doing wrong?

Поиск
Список
Период
Сортировка
От Chris Ruprecht
Тема Re: Have: Seq Scan - Want: Index Scan - what am I doing wrong?
Дата
Msg-id 2A64CF51-CC89-4A0A-89CC-49D7ABFD4603@cdrbill.com
обсуждение исходный текст
Ответ на Re: Have: Seq Scan - Want: Index Scan - what am I doing wrong?  (Evgeny Shishkin <itparanoia@gmail.com>)
Ответы Re: Have: Seq Scan - Want: Index Scan - what am I doing wrong?  (Bruce Momjian <bruce@momjian.us>)
Список pgsql-performance
On Oct 16, 2012, at 20:01 , Evgeny Shishkin <itparanoia@gmail.com> wrote:

> Selecting 5 yours of data is not selective at all, so postgres decides it is cheaper to do seqscan.
>
> Do you have an index on patient.dnsortpersonnumber? Can you post a result from
> select count(*) from patient where dnsortpersonnumber = '347450'; ?
>

Yes, there is an index:

"Aggregate  (cost=6427.06..6427.07 rows=1 width=0)"
"  ->  Index Scan using patient_pracsortpatientnumber on patient  (cost=0.00..6427.06 rows=1 width=0)"
"        Index Cond: (dnsortpersonnumber = '347450'::text)"


In fact, all the other criteria is picked using an index. I fear that the >= and <= on the timestamp is causing the
issue.If I do a "=" of just one of them, I get an index scan. But I need to scan the entire range. I get queries like
"giveme everything that was entered into the system for this patient between these two dates". A single date wouldn't
work.

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

Предыдущее
От: Evgeny Shishkin
Дата:
Сообщение: Re: Have: Seq Scan - Want: Index Scan - what am I doing wrong?
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: Have: Seq Scan - Want: Index Scan - what am I doing wrong?