pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Rahul Sharma <rahul.sharma1@oyorooms.com>
Cc: pgsql-general@postgresql.org
Cc: Jagbir Singh <jagbir.singh1@oyorooms.com>
Cc: Sonender Singh <sonender.singh@oyorooms.com>
Cc: Rishikesh kumar <rishikesh.kumar@oyorooms.com>
Cc: Ishank Singh <ishank.singh@oyorooms.com>
Subject: Re: Postgres 9.4 using primary key index in almost all queries leading to degraded performance
Date: Sat, 13 Jan 2018 12:08:39 -0500
Message-ID: <12540.1515863319@sss.pgh.pa.us> (raw)
In-Reply-To: <CAEA5Rf8HSfd92cKHskOu-mUo-B9Fazvj3eQaRbV2cE2qkmCkLA@mail.gmail.com>
References: <CAEA5Rf8HSfd92cKHskOu-mUo-B9Fazvj3eQaRbV2cE2qkmCkLA@mail.gmail.com>

Rahul Sharma <rahul.sharma1@oyorooms.com> writes:
> We're currently testing out upgrade of our Postgres database from 9.3.14 to
> 9.4.9. We are using Amazon RDS. We've encountered an issue in testing
> phase  where after the upgrade, CPU utilization hovers around 100%. We dug
> deep to find that the queries which executed in a few milliseconds on
> Postgres 9.3.14 are taking a lot of time to complete on 9.4.9. We've
> noticed a pattern under which the query planner (in almost all queries) is
> using primary key index for scanning the table while ignoring other
> alternatives like explicit sorting or using another efficient index present
> on the table.

In all the examples you show, the rowcount estimates are substantially
different in 9.3 and 9.4 --- and at least in the non-LIMITed queries,
where it's possible to verify the estimates, 9.3 is reasonably on-target
but 9.4 is awful.  So your problem is not with the costs but with the
selectivity estimates.  Has the 9.4 database been ANALYZEd at all?  Maybe
you disabled auto-analyze?  Maybe the old DB has some special statistics
target settings that you neglected to port forward?

			regards, tom lane




view thread (2+ messages)

Message-ID: <12540.1515863319@sss.pgh.pa.us>
Permalink:  ../12540.1515863319@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/12540.1515863319@sss.pgh.pa.us

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, rahul.sharma1@oyorooms.com, jagbir.singh1@oyorooms.com, sonender.singh@oyorooms.com, rishikesh.kumar@oyorooms.com, ishank.singh@oyorooms.com
  Subject: Re: Postgres 9.4 using primary key index in almost all queries leading to degraded performance
  In-Reply-To: <12540.1515863319@sss.pgh.pa.us>
  References: <CAEA5Rf8HSfd92cKHskOu-mUo-B9Fazvj3eQaRbV2cE2qkmCkLA@mail.gmail.com> <12540.1515863319@sss.pgh.pa.us>

* 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