Queries not using Index
Queries not using Index
От:
Daryl Herzmann <akrherz@iitap.iastate.edu>
Дата:
(sorry if you get this twice, my first post bounced since I did not use the subscribed email account. I assume that those messages get discarded...) Greetings, I suppose I should have sent this to pgsql-bugs maybe? I would appreciate it if anybody could help me out. I can't figure out what is going on here... snet=# select version(); version -------------------------------------------------------------PostgreSQL 7.2.1 on i686-pc-linux-gnu, compiled by GCC 2.96 snet=# \d t2002_06 Table "t2002_06"Column | Type | Modifiers ---------+--------------------------+-----------station | character varying(5) | valid | timestamp with time zone | tmpf | smallint | dwpf | smallint | drct | smallint | sknt | real | pday | real | pmonth | real | srad | real | relh | real | alti | real | Indexes: t2002_06_station_idx, t2002_06_tmpf_idx snet=# \d t2002_06_station_idx; Index "t2002_06_station_idx"Column | Type ---------+----------------------station | character varying(5) snet=# select count(valid) from t2002_06; count ---------1513895 snet=# vacuum analyze t2002_06; VACUUM snet=# vacuum t2002_06; VACUUM 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) EXPLAIN Shouldn't this be an index scan? I hope that I am not doing something stupid, although I probably am :( I even just tried this drop index t2002_06_station_idx; vacuum analyze t2002_06; create index t2002_06_station_idx on t2002_06(station); vacuum analyze t2002_06; And I still get a Seq Scan. Augh.... Thanks, Daryl
Re: Queries not using Index
От:
Stephan Szabo <sszabo@megazone23.bigpanda.com>
Дата:
On Mon, 22 Jul 2002, Daryl Herzmann wrote: > 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) > > EXPLAIN What does explain show if you do set enable_seqscan=off; ? It's possible that it's estimating a greater cost for the index scan.