Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 7C3F41337B9A for ; Fri, 15 Oct 2010 15:35:14 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 00459-10 for ; Fri, 15 Oct 2010 18:35:06 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 089851337B64 for ; Fri, 15 Oct 2010 15:35:05 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o9FIZ4Ou007192; Fri, 15 Oct 2010 14:35:04 -0400 (EDT) To: Brandon Casci cc: pgsql-performance@postgresql.org Subject: Re: help with understanding EXPLAIN and boosting performance In-reply-to: References: Comments: In-reply-to Brandon Casci message dated "Wed, 13 Oct 2010 18:06:44 -0400" Date: Fri, 15 Oct 2010 14:35:03 -0400 Message-ID: <7191.1287167703@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201010/261 X-Sequence-Number: 40679 Brandon Casci 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