Hello. I have a table with, say, three fields. The first is the ID (integer,
unique, primary index). The second is an optional index that sometimes can be
blank, or even duplicated, a varchar(13). The third one is the data I want to
retrieve, it has no importance in this problem. I need to access sometimes by the
ID and sometimes by the secondary key, so I made an index using
CREATE INDEX my_index_name ON MY_TABLE(my_secondary_id);
When I select using the primary key, obviously uses the index created by default.
When I select using the secondary key, it EXPLAINs me that it would use sequencial
scan instead of the index I created, thus this search becomes extremely slow. Why
the engine would ignore the index? Do I have to make it "available" in some way I
am not aware of? I VACUUM ANALYZEd already, and nothing changed.
I thank you in advance any help.
In response to
pgsql-novice by date
|Next:||From: Tom Lane||Date: 2001-02-08 19:22:04|
|Subject: Re: Secondary indexes |
|Previous:||From: Etienne De Kerckhove||Date: 2001-02-07 21:23:59|