Re: Query Plan - Index Scan & Seq Scan

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Query Plan - Index Scan & Seq Scan
Дата
Msg-id 2052.1115913920@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Query Plan - Index Scan & Seq Scan  (Prasanth <dbadmin@nqadmin.com>)
Ответы Re: Query Plan - Index Scan & Seq Scan  (Prasanth <dbadmin@nqadmin.com>)
Список pgsql-admin
Prasanth <dbadmin@nqadmin.com> writes:
> A where condition I always use is shown below. This is bringing down the number
> of rows from 6.5m to 1210. I have an index on code also. Even here it is going
> for seq scan.

> EXPLAIN ANALYZE SELECT count(*) fROM a where Code >2;
>                                                           QUERY PLAN
>
-------------------------------------------------------------------------------------------------------------------------------
>  Aggregate  (cost=141321.09..141321.09 rows=1 width=0) (actual
> time=6454.063..6454.064 rows=1 loops=1)
>    ->  Seq Scan on a  (cost=0.00..141318.40 rows=1076 width=0) (actual
> time=15.687..6453.292 rows=1210 loops=1)
>          Filter: (code > 2)
>  Total runtime: 6454.140 ms
> (4 rows)

I'm going to hazard a guess that "code" is not of type integer, and that
you're using a pre-8.0 PG release.  Cross-type comparisons are not
indexable before 8.0, so you need to cast the integer constant 2 to
whatever type "code" is.

            regards, tom lane

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

Предыдущее
От: Scott Marlowe
Дата:
Сообщение: Re: Query Plan - Index Scan & Seq Scan
Следующее
От: Prasanth
Дата:
Сообщение: Re: Query Plan - Index Scan & Seq Scan