Re: Index not being used ?

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: Index not being used ?
Дата
Msg-id 20030903144845.L11663-100000@megazone.bigpanda.com
обсуждение исходный текст
Ответ на Index not being used ?  (Carlos G Mendioroz <tron@huapi.ba.ar>)
Список 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.


В списке pgsql-general по дате отправления:

Предыдущее
От: Ron Johnson
Дата:
Сообщение: Re: About GPL and proprietary software
Следующее
От: Josué Maldonado
Дата:
Сообщение: Re: TCL trigger doesn't work after deleting a column