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.
Leandro.