Re: 8.4 index no funciona con 158 mil registros

From: Rodrigo Gonzalez <rjgonzale(dot)lists(at)gmail(dot)com>
To: William Diaz Pabón <widipa(at)gmail(dot)com>
Cc: PostgreSQL Español Ayuda <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: 8.4 index no funciona con 158 mil registros
Date: 2013-06-25 22:48:11
Message-ID: 20130625194811.4049cce7@rjgonzale-laptop
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

On Tue, 25 Jun 2013 17:25:21 -0500
William Diaz Pabón <widipa(at)gmail(dot)com> wrote:

> Saludos lista.
>
> Tengo esta BD
>
> Version string PostgreSQL 8.4.17 on i686-pc-linux-gnu, compiled by
> GCC gcc (GCC) 4.4.6 20120305 (Red Hat 4.4.6-4), 32-bit
>
> Donde tengo una tabla con un campo estado que tiene esta constraint
>
> CHECK (estado::text = 'ACTIVO'::text OR estado::text =
> 'INACTIVO'::text OR estado::text = 'PAGADO'::text OR estado::text =
> 'CANJE'::text OR estado::text = 'LIQUIDADO'::text OR estado::text =
> 'CONVENIO'::text OR estado::text = 'REFINANCIADO'::text OR
> estado::text = 'PRESCRITO'::text),
>
> cuando hago un select donde el where hace *estado = 'INACTIVO'* y
> hago un explain query me indica que esta usando el indice.
>
> pero cuando hago *estado = 'ACTIVO'* y hago un explain query me
> indica que NO esta usando el indice. y me dice que hay 158 mil filas.
>
> como se hace para que sin importar la cantidad de registros use
> siempre el indice?

No se puede, si tenes 158 mil registros con estado = ACTIVO y queres
ver esos registros siempre tiene que usar seqscan porque es mas
efectivo que usar el indice....ahora si, el numero esta equivocado por
favor pasa select estado, count(*) from <tabla> group by 1; para ver
que esta pasando....

>
> PD: Ya le hice un vacuum y nada.
>
>

-
Enviado a la lista de correo pgsql-es-ayuda (pgsql-es-ayuda(at)postgresql(dot)org)
Para cambiar tu suscripcin:
http://www.postgresql.org/mailpref/pgsql-es-ayuda

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Jaime Casanova 2013-06-26 03:56:02 Re: 8.4 index no funciona con 158 mil registros
Previous Message William Diaz Pabón 2013-06-25 22:25:21 8.4 index no funciona con 158 mil registros