From: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
---|---|
To: | Carlos G Mendioroz <tron(at)huapi(dot)ba(dot)ar> |
Cc: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Index not being used ? |
Date: | 2003-09-03 21:50:22 |
Message-ID: | 20030903144845.L11663-100000@megazone.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, 2 Sep 2003, Carlos G Mendioroz wrote:
> Hi,
> I'm trying to understand why a perfect match index is not being used,
> and a sequence scan is done in place:
>
> PostgreSQL 7.3.4 on i686-pc-cygwin, compiled by GCC gcc (GCC) 3.2
> 20020927 (prerelease)
>
> I've a table with 7M records, and an index on 3 fields:
>
> CREATE TABLE public.base (
> nombre varchar(255),
> calle varchar(255),
> puerta int2,
> resto varchar(255),
> lid int2,
> area varchar(4),
> telefono varchar(10)
> )
> CREATE INDEX base_dir ON base USING btree (lid, calle, puerta);
>
> And trying the following select:
>
> select * from base where lid = 457 and calle = 'MALABIA' and puerta = 10
Try one of
lid='457' and puerta='10'
lid=457::int2 and puerta=10::int2
lid=CAST(457 as int2) and puerta=CAST(10 as int2)
The constants get typed as int4 and so it doesn't realize it can use the
index, you can check the archives for more information.
From | Date | Subject | |
---|---|---|---|
Next Message | Ron Johnson | 2003-09-03 21:53:47 | Re: About GPL and proprietary software |
Previous Message | Gregory S. Williamson | 2003-09-03 21:40:15 | Re: setting last_value of sequence |