From: | Daryl Herzmann <akrherz(at)iastate(dot)edu> |
---|---|
To: | Elielson Fontanezi <ElielsonF(at)prodam(dot)sp(dot)gov(dot)br> |
Cc: | pgsql-sql <pgsql-sql(at)postgresql(dot)org>, pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: RES: [SQL] Queries not using Index |
Date: | 2002-07-24 15:45:53 |
Message-ID: | Pine.LNX.4.33.0207240947480.11932-100000@pircsds0.agron.iastate.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-sql |
Hi!
Thanks for the help. Please see my responses below.
On Wed, 24 Jul 2002, Elielson Fontanezi wrote:
> What kind of index is t2002_06_station_idx?
snet=# select indexdef from pg_indexes where
indexname='t2002_06_station_idx';
indexdef
---------------------------------------------------------------------
CREATE INDEX t2002_06_station_idx ON t2002_06 USING btree (station)
> Have you done this SELECT command below, right?
> select * from t2002_06 WHERE station = 'SAMI4';
Yes.
> This SELECT causes a sequention scan 'cause your index
>is not HASH type, but likely a BTREE one.
> BTREE index is to interval searches (station = 'SAMI4%')
>not precise searchs. (station = 'SAMI4').
I have created similar tables in the past and have never had this INDEX
problem. It was suggested that this 'problem' was a result of the way I
loaded the data into the database. So anyway, I will try your HASH type
idea.
snet=# drop index t2002_06_station_idx;
DROP
snet=# vacuum analyze t2002_06;
VACUUM
snet=# create index t2002_06_station_hash_idx ON t2002_06 USING
hash(station);
CREATE
(((((((((((((( This create took a VERY long time, 40 minutes or so )))
snet=# vacuum analyze t2002_06;
VACUUM
snet=# vacuum analyze;
VACUUM
snet=# explain analyze select * from t2002_06 WHERE station = 'SAMI4';
NOTICE: QUERY PLAN:
Seq Scan on t2002_06 (cost=0.00..35379.69 rows=35526 width=47) (actual
time=20.23..2358.40 rows=38146 loops=1)
Total runtime: 2452.14 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_hash_idx on t2002_06
(cost=0.00..132190.93 rows=34949 width=47) (actual time=0.14..306.90
rows=38146 loops=1)
Total runtime: 325.22 msec
EXPLAIN
Thanks for the help! I am still reading up on some clustering pointers
and messing with the pg_statistics table. Interesting stuff!
Thanks again,
Daryl
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2002-07-24 15:47:14 | Re: need help : how to replace / extend existing SQL operators ? |
Previous Message | Tom Lane | 2002-07-24 15:29:54 | Re: column limit? |
From | Date | Subject | |
---|---|---|---|
Next Message | Christopher Kings-Lynne | 2002-07-24 15:48:08 | Re: [SQL] Queries not using Index |
Previous Message | Stephan Szabo | 2002-07-24 15:18:06 | Re: RES: [SQL] Queries not using Index |