Re: help with understanding EXPLAIN and boosting performance

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Brandon Casci <brandon(at)loudcaster(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: help with understanding EXPLAIN and boosting performance
Date: 2010-10-15 18:35:03
Message-ID: 7191.1287167703@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Brandon Casci <brandon(at)loudcaster(dot)com> writes:
> I have an application hosted on Heroku. They use postgres. It's more or less
> abstracted away, but I can get some performance data from New Relic. For the
> most part, performance is ok, but now and then some queries take a few
> seconds, and spike up to 15 or even 16 seconds! Ouch!

The particular query you're showing here doesn't look terribly
expensive. Are you sure this is one that took that long?

If you're seeing identical queries take significantly different times,
I'd wonder about what else is happening on the server. The most obvious
explanation for that type of behavior is that everything is swapped into
RAM when it's fast, but has to be read from disk when it's slow. If
that's what's happening you should consider buying more RAM or
offloading some activities to other machines, so that there's not so
much competition for memory space.

If specific queries are consistently slow then EXPLAIN might give some
useful info about those. It's unlikely to tell you much about
non-reproducible slowdowns, though.

regards, tom lane

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Igor Neyman 2010-10-15 18:54:11 Re: oracle to psql migration - slow query in postgres
Previous Message Tom Lane 2010-10-15 18:29:27 Re: Index scan / Index cond limitation or ?