pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: banghe <banghe@baileylink.net>
To: Markus Espenhain <espenhain@etes.de>
Cc: Postgres <pgsql-admin@postgresql.org>
Subject: Re: SQL-Statement
Date: Thu, 13 Nov 2003 12:14:05 -0600
Message-ID: <3FB3C9ED.5000603@baileylink.net> (raw)
In-Reply-To: <20031113172327.GB24750@intranet.etes.de>
References: <20031113172327.GB24750@intranet.etes.de>

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
>
>  
>




view thread (6+ messages)

Message-ID: <3FB3C9ED.5000603@baileylink.net>
Permalink:  ../3FB3C9ED.5000603@baileylink.net/
Also on:    postgresql.org/message-id/3FB3C9ED.5000603@baileylink.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: banghe@baileylink.net, espenhain@etes.de
  Subject: Re: SQL-Statement
  In-Reply-To: <3FB3C9ED.5000603@baileylink.net>
  References: <20031113172327.GB24750@intranet.etes.de> <3FB3C9ED.5000603@baileylink.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox