Re: Indices y mas indices....

From: "Roberto Guevara" <cygnus2k(at)gmail(dot)com>
To: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: Indices y mas indices....
Date: 2006-08-24 16:16:15
Message-ID: 57650fe50608240916i6e7a42cay685b0482a487568@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

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. ¿?

2006/8/24, Jaime Casanova <systemguards(at)gmail(dot)com>:
> On 8/24/06, Roberto Guevara <cygnus2k(at)gmail(dot)com> wrote:
> > El EXPLAIN ANALIZE :
> > -----------------------------------------------------------------
> > Result (cost=0.00..4.83 rows=1 width=390) (actual time=0.01..0.01
> > rows=0 loops=1)
> > -> Index Scan using detmov_enti on detmov (cost=0.00..4.83 rows=1
> > width=390) (never executed)
> > Index Cond: ((dm_emp = 1::numeric) AND (dm_enti = 71::numeric))
> > Filter: (dm_rnmov IS NULL)
> > Filter: (dm_cta ~~ '90000'::text)
> >
> > Total runtime: 3.91 msec
> > -----------------------------------------------------------------
> >
> > Me trae el siguiente resultado:
> >
> > dm_emp dm_tcom dm_ope dm_nmov dm_cta dm_conc dm_sec dm_cope dm_cfin dm_enti dm_rtcom dm_rope dm_rnmov
> > 1 FC 1 2136 90000 cdf 1 NULL
> >
> > Que es el esperado.
> >
>
> No es el esperado en realidad, me llama la atencion que actual rows
> dice 0 pero te esta regresando un registro... es esto correcto (la
> logica me dice que no, pero ya me he equivocado antes ;)?
>
> btw, que version de postgres estas usando? quiza eres victima de
> algunos de los bugs que se han corregido en meses anteriores...
>
> --
> Atentamente,
> Jaime Casanova
>
> "Programming today is a race between software engineers striving to
> build bigger and better idiot-proof programs and the universe trying
> to produce bigger and better idiots.
> So far, the universe is winning."
> Richard Cook
>

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Ana Smail 2006-08-24 16:23:12 Backup de Roles y Usuarios
Previous Message Roberto Guevara 2006-08-24 16:04:16 Re: Indices y mas indices....