Hola

Tengo una duda de cuando postgres realiza una búsqueda por índice.

test=# \d foo
        Tabla «public.foo»
 Columna |  Tipo   | Modificadores 
---------+---------+---------------
 unique1 | integer | 
 unique2 | integer | 
Índices:
    "fooi" btree (unique1, unique2)

Si realizo una búsqueda filtrando por la columna unique2 realiza una
búsqueda secuencial.

test=# explain select * from foo where unique2 in (1,2,3);
                     QUERY PLAN                      
-----------------------------------------------------
 Seq Scan on foo  (cost=0.00..182.50 rows=3 width=8)
   Filter: (unique2 = ANY ('{1,2,3}'::integer[]))
(2 filas)

Sin embargo si filtro por la columna unique1 la búsqueda se realiza por
índice.

test=# explain select * from foo where unique1 in (1,2,3);
                              QUERY PLAN                              
----------------------------------------------------------------------
 Index Only Scan using fooi on foo  (cost=0.00..20.32 rows=3 width=8)
   Index Cond: (unique1 = ANY ('{1,2,3}'::integer[]))
(2 filas)

¿Porqué ambas búsquedas no realizan utilizando el índice?

Saludos.



Fin a la injusticia, LIBERTAD AHORA A NUESTROS CINCO COMPATRIOTAS QUE SE 
ENCUENTRAN INJUSTAMENTE EN PRISIONES DE LOS EEUU!
http://www.antiterroristas.cu
http://justiciaparaloscinco.wordpress.com
-
Enviado a la lista de correo pgsql-es-ayuda (pgsql-es-ayuda@postgresql.org)
Para cambiar tu suscripci�n:
http://www.postgresql.org/mailpref/pgsql-es-ayuda

Responder a