Re: Performance of outer joins?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: ben(at)charterworks(dot)net
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Performance of outer joins?
Date: 2006-12-16 22:51:30
Message-ID: 8617.1166309490@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Benjamin Smith <ben(at)schoolpathways(dot)com> writes:
> FROM customers
> JOIN calendars ON
> (
> -- GIVE A CALENDAR OF POSSIBLE DAYS FOR DELIVERIES
> calendar.day < 20061201
> AND calendar.day >= 20060101
> )

Haven't you written a cross-product join here? Seems like a bad
idea if you'd like it to be fast. Especially since you then left-joined
it to something else, meaning that every row in the cross product
must in fact generate output. Do you really want to be deluged with
a table showing all the customers you DIDN'T deliver to on each day,
for every day in the year?

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message TJ O'Donnell 2006-12-16 22:55:20 Re: Functions on tables
Previous Message Magnus Hagander 2006-12-16 22:14:15 Re: Failed to set permision Win2k3-PG Installation Issues