From: Prasanth <dbadmin@nqadmin.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-admin@postgresql.org
Subject: Re: Query Plan - Index Scan & Seq Scan
Date: Thu, 12 May 2005 11:18:11 -0500
Message-ID: <428381C3.80205@nqadmin.com> (raw)
In-Reply-To: <2052.1115913920@sss.pgh.pa.us>
References: <428370AC.3070207@nqadmin.com>
<886.1115910870@sss.pgh.pa.us>
<428379E0.4010709@nqadmin.com>
<2052.1115913920@sss.pgh.pa.us>
code data type is int2.
I am sorry that I did not mention the version number
I am using 7.4.7.
Thanks,
-Prasanth.
Tom Lane wrote:
> 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
>
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: dbadmin@nqadmin.com, tgl@sss.pgh.pa.us
Subject: Re: Query Plan - Index Scan & Seq Scan
In-Reply-To: <428381C3.80205@nqadmin.com>
References: <428370AC.3070207@nqadmin.com> <886.1115910870@sss.pgh.pa.us> <428379E0.4010709@nqadmin.com> <2052.1115913920@sss.pgh.pa.us> <428381C3.80205@nqadmin.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox