Re: Queries not using Index - Mailing list pgsql-sql

From Daryl Herzmann
Subject Re: Queries not using Index
Date
Msg-id Pine.LNX.4.44.0207230822520.1171-100000@akrherz.agron.iastate.edu
Whole thread Raw
In response to Re: Queries not using Index  ("Gaetano Mendola" <mendola@bigfoot.com>)
List pgsql-sql
Hi!

Thanks for your help!

On Tue, 23 Jul 2002, Gaetano Mendola wrote:

>"Daryl Herzmann" <akrherz@iastate.edu> wrote:
>> snet=# select count(valid) from t2002_06;
>>   count  
>> ---------
>>  1513895
>
>> snet=# explain SELECT * from t2002_06 WHERE station = 'SGLI4';
>> NOTICE:  QUERY PLAN:
>> 
>> Seq Scan on t2002_06  (cost=0.00..35379.69 rows=35564 width=47)
>
>
>Can you do the following query for better understand your situation ?
>
>select count(*) from t2002_06 where station = 'SGLI4';

snet=# select count(*) from t2002_06 where station = 'SGLI4';count 
-------39319


>select count(*) from t2002_06;

snet=# select count(*) from t2002_06; count  
---------1513895

In another email, it was suggested that I do this...

snet=# explain analyze select * from t2002_06 WHERE station = 'SAMI4';
NOTICE:  QUERY PLAN:

Seq Scan on t2002_06  (cost=0.00..35379.69 rows=34979 width=47) (actual 
time=67.89..3734.93 rows=38146 loops=1)
Total runtime: 3748.33 msec

EXPLAIN


snet=# set enable_seqscan=off;
SET VARIABLE
snet=# explain analyze select * from t2002_06 WHERE station = 'SAMI4';
NOTICE:  QUERY PLAN:

Index Scan using t2002_06_station_idx on t2002_06  (cost=0.00..132124.96 
rows=34979 width=47) (actual time=72.03..298.85 rows=38146 loops=1)
Total runtime: 317.76 msec

EXPLAIN

Thanks so much! Daryl




pgsql-sql by date:

Previous
From: Peter Atkins
Date:
Subject: Return Primary Key from Procedure
Next
From: "Sandro Joel Eller"
Date:
Subject: Re: Scan SQL