Re: Queries not using Index

From: Daryl Herzmann <akrherz(at)iastate(dot)edu>
To: Gaetano Mendola <mendola(at)bigfoot(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Queries not using Index
Date: 2002-07-23 13:26:25
Message-ID: Pine.LNX.4.44.0207230822520.1171-100000@akrherz.agron.iastate.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi!

Thanks for your help!

On Tue, 23 Jul 2002, Gaetano Mendola wrote:

>"Daryl Herzmann" <akrherz(at)iastate(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Andreas Joseph Krogh 2002-07-23 14:13:09 Re: Editor for pgsql
Previous Message Sandro Joel Eller 2002-07-23 13:11:18 Scan SQL