From: | William Diaz Pabón <widipa(at)gmail(dot)com> |
---|---|
To: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
Cc: | PostgreSQL Español Ayuda <pgsql-es-ayuda(at)postgresql(dot)org> |
Subject: | Re: Consulta no usa los indices |
Date: | 2014-03-14 16:04:30 |
Message-ID: | CAGrLqMb12p6tmZE+sv0OfDEKyenfS9-zx_CUs1+eg7U1xzV8CQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
Hash Join (cost=62.82..2455.25 rows=102826 width=11) (actual
time=6.006..186.428 rows=100738 loops=1)
Output: t.consecutivo, cpp.oi_predio
Hash Cond: ((cpp.caracteristica_predio)::text =
(cpt.caracteristica_predio)::text)
Join Filter: (((cpp.vigencia)::text = ''::text) OR (cpp.vigencia IS NULL)
OR ((cpp.vigencia)::text = (t.vigencia)::text))
-> Seq Scan on caracteristica_predio_oi_predio cpp (cost=0.00..162.44
rows=8595 width=29) (actual time=0.019..12.759 rows=8595 loops=1)
Output: cpp.consecutivo, cpp.caracteristica_predio, cpp.oi_predio,
cpp.vigencia, cpp.estado
Filter: ((estado)::text = 'ACTIVO'::text)
-> Hash (cost=59.97..59.97 rows=228 width=13) (actual time=5.970..5.970
rows=228 loops=1)
Output: t.consecutivo, t.vigencia, cpt.caracteristica_predio
-> Hash Join (cost=7.13..59.97 rows=228 width=13) (actual
time=0.755..5.571 rows=228 loops=1)
Output: t.consecutivo, t.vigencia, cpt.caracteristica_predio
Hash Cond: ((t.consecutivo)::text = (cpt.tarifa)::text)
-> Seq Scan on tarifa t (cost=0.00..44.66 rows=1573
width=10) (actual time=0.006..2.402 rows=1573 loops=1)
Output: t.consecutivo, t.avaluo_inicial,
t.avaluo_final, t.destino_economico, t.tipo_predio, t.tarifa, t.estado,
t.area_construida_inicial, t.area_construida_final, t.area_terreno_inicial,
t.area_terreno_final, t.estrato, t.tipo, t.fecha_cambio, t.registrado_por,
t.fecha_creacion, t.usuario_creacion, t.vigencia,
t.porcentaje_limite_incremento, t.uso_predio
Filter: ((estado)::text = 'ACTIVO'::text)
-> Hash (cost=4.28..4.28 rows=228 width=8) (actual
time=0.691..0.691 rows=228 loops=1)
Output: cpt.tarifa, cpt.caracteristica_predio
-> Seq Scan on caracteristica_predio_tarifa cpt
(cost=0.00..4.28 rows=228 width=8) (actual time=0.008..0.306 rows=228
loops=1)
Output: cpt.tarifa, cpt.caracteristica_predio
Total runtime: 308.551 ms
El 14 de marzo de 2014, 11:02, Alvaro Herrera
<alvherre(at)2ndquadrant(dot)com>escribió:
> William Diaz Pabón escribió:
> > Ok, gracias.
> >
> > Esta es la consulta con alias, espero que sea más legible:
> >
> >
> > SELECT
> > t.consecutivo AS tarifa,
> > cpp.oi_predio
> > FROM tarifa AS t
> > JOIN caracteristica_predio_tarifa AS cpt ON cpt.tarifa::text =
> > t.consecutivo::text
> >
> > JOIN caracteristica_predio_oi_predio AS cpp ON
> > cpp.caracteristica_predio::text = cpt.caracteristica_predio::text
> > AND cpp.estado::text = 'ACTIVO'::text
> > AND (cpp.vigencia::text = ''::text OR
> > cpp.vigencia IS NULL OR
> > cpp.vigencia::text = t.vigencia::text)
> > WHERE t.estado::text = 'ACTIVO'::text
>
> Sí, es mucho más legible. ¿Puedes mandar un EXPLAIN ANALYZE de la
> consulta?
>
> --
> Álvaro Herrera http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Training & Services
>
--
Éxitos.
Cordialmente,
*William Diaz Pabón*
*, Especialista en Soluciones Informáticas*
Bogotá, Colombia
Tel: +57 (300) 3917774
http://planetapleno.blogspot.com/
http://tutorialestecnicos.blogspot.com/
From | Date | Subject | |
---|---|---|---|
Next Message | raul andrez gutierrez alejo | 2014-03-14 16:09:42 | Re: Consulta no usa los indices |
Previous Message | Alvaro Herrera | 2014-03-14 16:02:52 | Re: Consulta no usa los indices |