Skip site navigation (1) Skip section navigation (2)

Re: Query Plan - Index Scan & Seq Scan

From: Prasanth <dbadmin(at)nqadmin(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Query Plan - Index Scan & Seq Scan
Date: 2005-05-12 16:18:11
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-admin
code data type is int2.

I am sorry that I did not mention the version number

I am using 7.4.7.


Tom Lane wrote:
> Prasanth <dbadmin(at)nqadmin(dot)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

In response to


pgsql-admin by date

Next:From: Tom LaneDate: 2005-05-12 16:30:06
Subject: Re: Query Plan - Index Scan & Seq Scan
Previous:From: PrasanthDate: 2005-05-12 16:16:04
Subject: Re: Query Plan - Index Scan & Seq Scan

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group