Skip site navigation (1) Skip section navigation (2)

Re: Indices y mas indices....

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Roberto Guevara <cygnus2k(at)gmail(dot)com>
Cc: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: Indices y mas indices....
Date: 2006-08-24 16:29:09
Message-ID: 20060824162909.GD19096@alvh.no-ip.org (view raw or flat)
Thread:
Lists: pgsql-es-ayuda
Roberto Guevara escribió:
> Corrijo el SQL:
> 
> SELECT * FROM admin.detmov
> WHERE
>    dm_emp=1
> AND dm_enti=71
> AND dm_cta LIKE '90000'
> AND dm_rnmov IS NULL
> ORDER BY dm_emp, dm_enti, dm_cta, dm_rnmov;
> 
> El ANALIZE EXPLAIN:
> Index Scan using detmov_enti on detmov  (cost=0.00..4.83 rows=1
> width=390) (actual time=3.29..3.49 rows=1 loops=1)
> 
>  Index Cond: ((dm_emp = 1::numeric) AND (dm_enti = 71::numeric))
> 
>  Filter: ((dm_cta ~~ '90000'::text) AND (dm_rnmov IS NULL))
> 
> Total runtime: 6.14 msec
> 
> Esta consulta me trae el resultado correcto. Si uso la otra consulta,
> con "=" en lugar de like, no me trae nada, pero si uso el "=" y le
> saco el ORDER BY (o sea, no usa el indice) entonces si me trae el
> resultado. ¿?

Dejame adivinar, dm_cta es un campo de tipo char(n)?

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to

pgsql-es-ayuda by date

Next:From: Roberto GuevaraDate: 2006-08-24 16:31:30
Subject: Re: Indices y mas indices....
Previous:From: Jaime CasanovaDate: 2006-08-24 16:29:00
Subject: Re: Indices y mas indices....

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group