From: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
---|---|
To: | Leonardo Boet Sánchez <boet(at)gtm(dot)tel(dot)etecsa(dot)cu> |
Cc: | pgsql-es-ayuda(at)postgresql(dot)org |
Subject: | Re: Consulta toma 100 Minutos!!?? |
Date: | 2005-09-07 20:44:18 |
Message-ID: | 20050907204418.GB8250@surnet.cl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
On Wed, Sep 07, 2005 at 03:20:51PM -0400, Leonardo Boet Sánchez wrote:
> Realmente haces bastante uso del motor con esto de "not in (select )"
> Verificas cada fila de la primera tabla y por cada de ellas unes nuevamente las 3 tablas y buscas en ellas.
>
> Yo lo haría de la siguiente manera y debe ser mucho mas eficiente. Si tienes los indices creados debe ser rapidísimo.
>
> SELECT "Rut Cliente"
> FROM "Internet_Abril" LEFT OUTER JOIN ((SELECT "Rut Cliente" FROM
> "Internet_Enero") UNION (SELECT "Rut Cliente" FROM
> "Internet_Febrero") UNION (SELECT "Rut Cliente" FROM
> "Internet_Marzo")) tlb1
> on "Internet_Abril"."Rut Cliente" = tlb1."Rut Cliente"
> WHERE tlb1."Rut Cliente" = null
Ojo con esta ultima linea, debe ser "IS NULL", no "= NULL". Esta ultima
condicion es siempre falsa (NULL nunca es igual a NULL, ningun valor es
igual a NULL).
--
Alvaro Herrera -- Valdivia, Chile Architect, www.EnterpriseDB.com
"Granting software the freedom to evolve guarantees only different results,
not better ones." (Zygo Blaxell)
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2005-09-07 20:52:07 | Re: Consulta |
Previous Message | Christian Compagnon | 2005-09-07 19:46:32 | Re: Consulta toma 100 Minutos!!?? |