From: | Paul Tomblin <ptomblin(at)xcski(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Ok, why isn't it using *this* index? |
Date: | 2001-04-01 19:38:32 |
Message-ID: | 20010401153832.A23595@allhats.xcski.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I have a table with columns 'country' and 'state'. I put indexes on both
of them. I've done the "vacuum analyze" as per the faq. But when I ask
it to explain, it says it will use the index on 'state' if I do a
select * from waypoint where state = 'ON';
but it won't use the index on 'country' if I do a
select * from waypoint where country = 'CANADA';
Some other interesting things are that it uses the index on state even if
I say "where state in ('ON','QC','BC','AB')", and it uses the index on
state but not the one on country if I combine "where state = 'ON' and
country = 'CANADA'".
Here's what it says:
waypoint=> explain select * from waypoint where state = 'ON';
NOTICE: QUERY PLAN:
Index Scan using waypoint_state on waypoint (cost=7.17 rows=84
width=130)
EXPLAIN
waypoint=> explain select * from waypoint where country = 'CANADA';
NOTICE: QUERY PLAN:
Seq Scan on waypoint (cost=455.13 rows=6813 width=130)
EXPLAIN
Also, can anybody explain why the "rows=" doesn't correspond to anything
logical? For instance, in the first one it says "rows=84" even though
there are 107 matching records, and 71 different states.
--
Paul Tomblin <ptomblin(at)xcski(dot)com>, not speaking for anybody
Diplomacy is the ability to let someone else have your way.
From | Date | Subject | |
---|---|---|---|
Next Message | Sean Harding | 2001-04-01 19:39:33 | another index question |
Previous Message | Daniel ?erud | 2001-04-01 19:02:54 | Re: Re: Dissapearing indexes, what's that all about? |