From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Francisco Reyes <lists(at)natserv(dot)com> |
Cc: | Pgsql Novice <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: Index not used on single select, but used in join. |
Date: | 2001-11-07 20:41:37 |
Message-ID: | 6461.1005165697@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Francisco Reyes <lists(at)natserv(dot)com> writes:
> I have a table, hraces, with a column called "horse" and an index
> "lower(horse)".
> If I try:
> explain select horse from hraces where lower(horse) = 'little irish nut';
> The query doesn't use the index. It says it would do a sequential scan.
Seems to work for me:
regression=# create table hraces (horse text);
CREATE
regression=# create index hri on hraces(lower(horse));
CREATE
regression=# explain select horse from hraces where lower(horse) = 'little irish nut';
NOTICE: QUERY PLAN:
Index Scan using hri on hraces (cost=0.00..17.08 rows=5 width=32)
EXPLAIN
What does EXPLAIN actually show for you? If you try to force an
indexscan by doing "SET enable_seqscan TO off", does the EXPLAIN
result change? Have you VACUUM ANALYZEd the table recently?
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | ben palmer | 2001-11-07 21:56:45 | portiny mysql to postgres, pg_fetch_array woes |
Previous Message | Tom Lane | 2001-11-07 20:31:27 | Re: IS NULL |