Re: Queries not using Index

Поиск
Список
Период
Сортировка
От Daryl Herzmann
Тема Re: Queries not using Index
Дата
Msg-id Pine.LNX.4.44.0207230822520.1171-100000@akrherz.agron.iastate.edu
обсуждение исходный текст
Ответ на Re: Queries not using Index  ("Gaetano Mendola" <mendola@bigfoot.com>)
Список 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 по дате отправления:

Предыдущее
От: Peter Atkins
Дата:
Сообщение: Return Primary Key from Procedure
Следующее
От: "Sandro Joel Eller"
Дата:
Сообщение: Re: Scan SQL