pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: LN Cisneros <lnsea@earthlink.net>
To: Manfred Koizar <mkoi-pg@aon.at>
To: Christopher Kings-Lynne <chriskl@familyhealth.com.au>
Cc: LN Cisneros <chulat@mail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: rewrite in to exists?
Date: Thu, 18 Sep 2003 07:59:54 -0700 (GMT-07:00)
Message-ID: <24864010.1063897195181.JavaMail.root@statler.psp.pas.earthlink.net> (raw)


On Thu, 18 Sep 2003 13:23:37 +0800, "Christopher Kings-Lynne"
<snip>

>To the original poster:  You did not provide a lot of information, but
>the following suggestions might give you an idea ...
<snip>
>

Yes, sorry about that. But in my query  for a set of dates returned from the subquery I would then like to get all records that match this set of dates (ordered).

I believe this query will work and hopefully speed it up (the "IN" query is extremely slow)...I give this one a try:

>SELECT t1.code, t1.id, t1.date_of_service
> FROM tbl t1 INNER JOIN
>       (SELECT DISTINCT date_of_service
>         FROM tbl
>         WHERE xxx >= '29800' AND xxx <= '29909'
>          AND code = 'XX'
>      ) AS t2 ON (t1.date_of_service = t2.date_of_service)
> WHERE t1.client_code = 'XX'
> ORDER BY id, date_of_service;

A question I have is is the "DISTINCT" really going to help or is it just going to throw another sort into the mix making it slower?

Thanks for the help!

Laurette





view thread (7+ messages)  latest in thread

Message-ID: <24864010.1063897195181.JavaMail.root@statler.psp.pas.earthlink.net>
Permalink:  ../24864010.1063897195181.JavaMail.root@statler.psp.pas.earthlink.net/
Also on:    postgresql.org/message-id/24864010.1063897195181.JavaMail.root@statler.psp.pas.earthlink.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-performance@postgresql.org
  Cc: lnsea@earthlink.net, mkoi-pg@aon.at, chriskl@familyhealth.com.au, chulat@mail.com
  Subject: Re: rewrite in to exists?
  In-Reply-To: <24864010.1063897195181.JavaMail.root@statler.psp.pas.earthlink.net>
  References: <24864010.1063897195181.JavaMail.root@statler.psp.pas.earthlink.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