Re: Query Plan difference between 9.3 and 9.5 for the worse. Help !!!

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jorge Torralba <jorge(dot)torralba(at)gmail(dot)com>
Cc: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Query Plan difference between 9.3 and 9.5 for the worse. Help !!!
Date: 2016-09-28 22:28:09
Message-ID: 31745.1475101689@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Jorge Torralba <jorge(dot)torralba(at)gmail(dot)com> writes:
> We have been struggling with a query on our system that under 9.3 was
> taking 15ms or so to run and after upgrading to 9.5 it is taking over
> 2500ms.
> You can see the explains are very different but I cannot figure out why
> when using the same data on both system.

Hard to comment on this when you haven't shown us the query nor the
table schemas. But I'm going to guess based on the lack of a Limit
node in the second plan that your query involves WHERE EXISTS(SELECT
... LIMIT 1). The LIMIT 1 would have defeated optimization till recently,
but now the planner knows that it's a no-op in this context and throws it
away, and then is able to convert the sub-select to a semijoin. Usually
that results in a better plan; there's far from enough info here to
guess why it's worse for you.

regards, tom lane

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Poul Kristensen 2016-09-29 18:47:46 Re: /var/run/postgresql/.s.PGSQL.5432 should be 5433
Previous Message Jorge Torralba 2016-09-28 17:53:32 Query Plan difference between 9.3 and 9.5 for the worse. Help !!!