Benjamin Smith <ben@xxxxxxxxxxxxxxxxxx> 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