Re: Inconsistent query performance

From: Ramsey Gurley <rgurley(at)smarthealth(dot)com>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Inconsistent query performance
Date: 2013-04-09 16:52:02
Message-ID: 331CB23D-090F-47DB-B73B-18DC954FB7A8@smarthealth.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Apr 8, 2013, at 8:46 PM, Jeff Janes wrote:

> On Monday, April 8, 2013, Ramsey Gurley wrote:
> Hi all,
>
> I'm having issues with slow queries using postgres, and I'm finding some of the issues difficult to reproduce. My application logs slow queries for me, but often, when I go back to run explain analyze on the query it is very fast. I assume this is due to some sort of caching. Here is an example:
>
> sqlLogging _valuesForSQL ran 116509ms with sql string:
>
> I think that your IO subsystem is getting congested on occasion, and that you have a "selection bias". You are seeing in your log the occasions on which it is running slow, but not seeing the occasions it is running fast. When you run it manually, you see a result similar to the (invisible, but frequent) times that it did not run slow.

I think you're right about this. It seems to run fast most of the time. It's those times it takes 2 minutes to respond to a customer which I'd like to minimize or eliminate.

But I think caching has a bit to do with it too. I can go back to the logs from last week and run a slow query and it will frequently be equally slow again. Not always, but enough that I think something else is wrong with my setup.

>
> You should monitor with sar, or iostat, or vmstat, or similar.

I'll look into that. Thanks Jeff :)

>
> Cheers,
>
> Jeff

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Christian Hammers 2013-04-09 17:07:12 Re: Queries seldomly take >4s while normally take <1ms?
Previous Message Ramsey Gurley 2013-04-09 16:52:01 Re: Inconsistent query performance