| From: | "macgillivary" <macgillivary(at)gmail(dot)com> | 
|---|---|
| To: | pgsql-general(at)postgresql(dot)org | 
| Subject: | Re: Performance of outer joins? | 
| Date: | 2006-12-17 14:14:17 | 
| Message-ID: | 1166364857.376420.26020@16g2000cwy.googlegroups.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
ben would something like this work in your situation?
SELECT customer.id, customer.name, deliveries.calendar_day,
deliveries.delivered
FROM ben_customers as customer, ben_deliveries as deliveries
WHERE customer.id = deliveries.customers_id
and deliveries.calendar_day in (Select day
				from ben_calendar
				where day < 20061201 and day >= 20060101)
I think that would cut down the deliveries table fairly quickly, thus
making the customer_id join nice and quick.  You would also only be
returning data from the tables in your from clause.  I suppose it
depends on what you are trying to display.  If you want a list of all
the possible days, and deliveries on those days then I'd approach it a
bit differently.
On Dec 15, 7:59 pm, b(dot)(dot)(dot)(at)schoolpathways(dot)com (Benjamin Smith) wrote:
>
> What can I do to improve the performance of this oft-used query? Is there a
> better way to do this, or am I doomed to looping thru results and parsing the
> results in code?
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Hannes Dorbath | 2006-12-17 14:48:06 | Re: PDOStatement:closeCursor | 
| Previous Message | Brendan Jurd | 2006-12-17 13:15:34 | Re: Functions on tables |