From: | banghe <banghe(at)baileylink(dot)net> |
---|---|
To: | Markus Espenhain <espenhain(at)etes(dot)de> |
Cc: | Postgres <pgsql-admin(at)postgresql(dot)org> |
Subject: | Re: SQL-Statement |
Date: | 2003-11-13 18:14:05 |
Message-ID: | 3FB3C9ED.5000603@baileylink.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
Hi,
Your query should be written in much simple way:
SELECT Monatsbeitrag.lfdid, Daten.Kundennummer FROM Daten, Monatsbeitrag
WHERE
(Daten.Vetrag widerufen = 2) AND
Daten.ewmanfrdat IS NOTNULL AND
(Monatsbeitrag.ID = Daten.Kundennummer ) AND
((Monatsbeitrag.Monat + 14 ) = '2003-10-27 00:00:00'::timestamp ) AND
(Monatsbeitrag.Bezahlt = 2 )
ORDER BY Daten.Name;
Your 2nd query has
Daten.ewmanfrdat IS NULL
So the result should is different and the cost for query will be
different too.
Bangh
Markus Espenhain wrote:
>Hello,
>
>sorry for my previos mail.
>This was a mistake...
>
>I have an problem with the following statement.
>This one works fine and give me the results in just a few seconds.
>
>SELECT Monatsbeitrag.lfdid, Daten.Kundennummer FROM Daten, Monatsbeitrag WHERE ((((Daten.Vetrag widerufen = 2 ) AND NOT((Daten.ewmanfrdat IS NULL ) ) ) AND (Monatsbeitrag.ID = Daten.Kundennummer ) ) AND (((Monatsbeitrag.Monat + 14 ) = '2003-10-27 00:00:00'::timestamp ) AND (Monatsbeitrag.Bezahlt = 2 ) ) ) ORDER BY Daten.Name;
>
>
>When I edit the statement and delete the "NOT" before "Daten.ewmanfrdat IS NULL" the Query works over 15 Minutes.
>
>SELECT Monatsbeitrag.lfdid, Daten.Kundennummer FROM Daten, Monatsbeitrag WHERE ((((Daten.Vetrag widerufen = 2 ) AND ((Daten.ewmanfrdat IS NULL ) ) ) AND (Monatsbeitrag.ID = Daten.Kundennummer )
>) AND (((Monatsbeitrag.Monat + 14 ) = '2003-10-27 00:00:00'::timestamp ) AND (Monatsbeitrag.Bezahlt = 2 ) ) ) ORDER BY Daten.Name;
>
>OK, to select a lot of records it works a time, but for only 350 records?
>
>Where is my problem?
>
>Can anybody help me please.
>
>Regards
>
>Markus
>
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | DHS Webmaster | 2003-11-13 20:36:38 | dropped users appear as numbers in ACL |
Previous Message | scott.marlowe | 2003-11-13 18:12:57 | Re: easy way to copy all DBs and users on a server |