Skip site navigation (1) Skip section navigation (2)

Re: rewrite in to exists?

From: LN Cisneros <lnsea(at)earthlink(dot)net>
To: Manfred Koizar <mkoi-pg(at)aon(dot)at>,Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
Cc: LN Cisneros <chulat(at)mail(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: rewrite in to exists?
Date: 2003-09-18 14:59:54
Message-ID: 24864010.1063897195181.JavaMail.root@statler.psp.pas.earthlink.net (view raw or flat)
Thread:
Lists: pgsql-performance
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



Responses

pgsql-performance by date

Next:From: Tom LaneDate: 2003-09-18 16:16:10
Subject: Re: [PERFORM] How to force an Index ?
Previous:From: Christopher Kings-LynneDate: 2003-09-18 14:47:03
Subject: Re: Is there a reason _not_ to vacuum continuously?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group