pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mario Splivalo <mario.splivalo@megafon.hr>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-performance@postgresql.org
Subject: Re: Planner choosing NestedLoop, although it is slower...
Date: Wed, 13 Jul 2011 02:53:32 +0200
Message-ID: <4E1CEC8C.3000508@megafon.hr> (raw)
In-Reply-To: <18737.1310510362@sss.pgh.pa.us>
References: <4E1C8E62.2090800@megafon.hr>
	<4626.1310501052@sss.pgh.pa.us>
	<4E1CC576.2080200@megafon.hr>
	<18737.1310510362@sss.pgh.pa.us>

On 07/13/2011 12:39 AM, Tom Lane wrote:
> Mario Splivalo<mario.splivalo@megafon.hr>  writes:
>> On 07/12/2011 10:04 PM, Tom Lane wrote:
>>> What you need to look into is why the estimated join size is 9400 rows
>>> when the actual join size is zero.  Are both tables ANALYZEd?  Are you
>>> intentionally selecting rows that have no join partners?
>
>> Yes, both tables have been ANALYZEd. What do you mean, intentilnaly
>> selecting rows taht have no join partners?
>
> I'm wondering why the actual join size is zero.  That seems like a
> rather unexpected case for a query like this.

Yes, seems that planer gets confused by LIMIT. This query:

select * from tubesite_object join tubesite_image on id=object_ptr_id 
where site_id = 8 and pub_date < '2011-07-12 13:25:00' order by pub_date 
desc ;

Does not choose Nested Loop, and is done instantly (20 ms), and returns 
no rows. However, if I add LIMIT at the end, it chooses NestedLoop and 
it takes 500ms if I'm alone on the server, and 10+ seconds if there 50+ 
connections on the server.

	Mario



view thread (8+ messages)  latest in thread

Message-ID: <4E1CEC8C.3000508@megafon.hr>
Permalink:  ../4E1CEC8C.3000508@megafon.hr/
Also on:    postgresql.org/message-id/4E1CEC8C.3000508@megafon.hr

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: mario.splivalo@megafon.hr, tgl@sss.pgh.pa.us
  Subject: Re: Planner choosing NestedLoop, although it is slower...
  In-Reply-To: <4E1CEC8C.3000508@megafon.hr>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox