Re: [PERFORM] Yet another slow nested loop

2009-06-16 Thread Robert Haas
On Tue, Jun 16, 2009 at 11:16 AM, Alexander Staubo wrote: > On Tue, Jun 16, 2009 at 4:36 PM, Tom Lane wrote: >> Actually the easiest way to fix that is to get rid of the LIMIT. >> (Maybe use a cursor instead, and fetch only twenty rows.)  LIMIT >> magnifies the risks from any estimation error, and

Re: [PERFORM] Yet another slow nested loop

2009-06-16 Thread Alexander Staubo
On Tue, Jun 16, 2009 at 4:36 PM, Tom Lane wrote: > Actually the easiest way to fix that is to get rid of the LIMIT. > (Maybe use a cursor instead, and fetch only twenty rows.)  LIMIT > magnifies the risks from any estimation error, and you've got a lot > of that here ... There's no cursor support

Re: [PERFORM] Yet another slow nested loop

2009-06-16 Thread Tom Lane
Alexander Staubo writes: > Here's the query: > select photos.* > from photos > inner join event_participations on > event_participations.user_id = photos.creator_id and > event_participations.attend = true > inner join event_instances on > event_instances.id = event_participations.event_inst

Re: [PERFORM] Yet another slow nested loop

2009-06-16 Thread Alexander Staubo
On Tue, Jun 16, 2009 at 3:56 PM, Dave Dutcher wrote: >> -Original Message- >> From: Alexander Staubo >> >>    ->  Nested Loop  (cost=0.00..5729774.95 rows=10420 width=116) >> (actual time=262614.470..262614.470 rows=0 loops=1) >>          Join Filter: ((photos.taken_at > (event_instances."t

Re: [PERFORM] Yet another slow nested loop

2009-06-16 Thread Dave Dutcher
> -Original Message- > From: Alexander Staubo > >-> Nested Loop (cost=0.00..5729774.95 rows=10420 width=116) > (actual time=262614.470..262614.470 rows=0 loops=1) > Join Filter: ((photos.taken_at > (event_instances."time" + > '-01:00:00'::interval)) AND (photos.taken_at < (e

[PERFORM] Yet another slow nested loop

2009-06-16 Thread Alexander Staubo
Here's the query: select photos.* from photos inner join event_participations on event_participations.user_id = photos.creator_id and event_participations.attend = true inner join event_instances on event_instances.id = event_participations.event_instance_id where ( (event_instances.venue_