Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VeQkj-00005Z-HU for pgsql-admin@arkaria.postgresql.org; Thu, 07 Nov 2013 14:40:09 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VeQkj-0007ea-03 for pgsql-admin@arkaria.postgresql.org; Thu, 07 Nov 2013 14:40:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VeQkh-0007d9-NE for pgsql-admin@postgresql.org; Thu, 07 Nov 2013 14:40:07 +0000 Received: from nm41-vm3.bullet.mail.bf1.yahoo.com ([216.109.114.158]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VeQkd-0000bw-Sq for pgsql-admin@postgresql.org; Thu, 07 Nov 2013 14:40:07 +0000 Received: from [98.139.212.151] by nm41.bullet.mail.bf1.yahoo.com with NNFMP; 07 Nov 2013 14:40:00 -0000 Received: from [98.139.212.224] by tm8.bullet.mail.bf1.yahoo.com with NNFMP; 07 Nov 2013 14:40:00 -0000 Received: from [127.0.0.1] by omp1033.mail.bf1.yahoo.com with NNFMP; 07 Nov 2013 14:40:00 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 906698.92672.bm@omp1033.mail.bf1.yahoo.com Received: (qmail 18748 invoked by uid 60001); 7 Nov 2013 14:40:00 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ymail.com; s=s1024; t=1383835200; bh=Q0Ys4xB3+qAcmWVLKl0TYIJYPT3bbPyXXzyX6FdSLDA=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=v5p0H/j9exqPf0knZK803MNfJox6LTBlXMw89zqSJKaFDenNaHLBm1b1w8/ofBPneySttkshrE4+lwMVQxEz41cvrP26MMjVs2Foe9VjPqYhasN3SBTFbMLYHq8EpxhiZfTuujQCtyX2oCgUeGk+djqqOYVnUjaOLKXiHvXrMbE= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=ymail.com; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=FQdDN3oErVCbxYi5jQpg9edSnxEWltar7xNEhKCXY/SfH3DeWhu0p8G3ucSKHLgr5vPuVgh+6zPwJotSUEEeRsHOD1z+oKSlzpvStuZEuWRDx74ZLYzaaZA+wF9wy24BcZdSbaDmedD5esjrlAgMfAXth7PcDMkWZhfwDH1Irxo=; X-YMail-OSG: 7wvoWDYVM1mp7x8ah_95lawISvlQTUuU7QXFkOm_d0FEj8E sLdWBHgyb5IfOxVrpbz_MC6zSZV.4FNbK5J4KSReeawlsdTINxL25Ri9hFeH SAjfocyXrAtprGkWa_1TeGVbeb4E6o6k.R2gsMIC97FO4DMIFhwnfvJvAfl2 sQTexJrPERmZuBEQ5kQoaKXLJSlOOpPxWeZpMENNJg3H8ytb9L3w7UY7SUPk AV98ldDDZ2xAM1hmFTRxsY3iBq60w5NJ9yAHqpSp3RMuz536YO.yBTBKYTjl i089x33fhnFRPiXbNpnXYzmHTqLGKSNGYBOT0W8lQ2wxrURbRDsAvUqmGFA5 IAa0.scOxHN6YO0zVp51yLy0IHxsxZZmBviWhYh5zKMrsGQIDCStnDydX1qG _iYeoY2syX3QiKGzB33vkE52wgbQblYu76VA6.APUTm2HrT2d_P3IoHRrtdF uLD.kpq6e01uc_Wy0DeAwFDtE5Vnpcl7MMpny4KtsnN9WwWd.OWBavhAMdQX iU4XL_AIfsfvOffakuZ0Qkoja3pRcvdNAurgn401o1ZaVtvXtDYf2pz6xrIh cZoIEbMuLv3nBWXQNThC27KsXve.sSvZBxzcYPP25ytii7jvfXRyTU7f1hgx 3RT22R7ac2YOU5kLItx0NtrAb2ovqRTcOYzWsgQUKIw9eKefmJ9WeAdBP741 iYXW1D7nNNoMNpyVQfsJwut8- Received: from [76.255.18.237] by web162905.mail.bf1.yahoo.com via HTTP; Thu, 07 Nov 2013 06:40:00 PST X-Rocket-MIMEInfo: 002.001, Um9iZXJ0IFZvaW5lYSA8cnZvaW5lYUBnbWFpbC5jb20.IHdyb3RlOgoKPiBGcm9tIHRpbWUgdG8gdGltZSAoMS0yIG1vbnRocykgb25lIG9mIHRoZSBwcm9kdWN0aW9uIHN5c3RlbXMgSQo.IG1hbmFnZSBzdGFydHMgYWN0aW5nIGNyYXp5Li4uIGFuZCB0aGlzIGlzIHN0YXJ0aW5nIHRvIGJlY29tZSBhCj4gcHJvYmxlbS4KPgo.IEV2ZXJ5IHF1ZXJ5IEkgc2VuZCB0byB0aGUgc2VydmVyIGhhcyBhIHZlcnkgbG9uZyBydW5uaW5nIHRpbWUKPiAoc29tZXRpbWVzIGl0IHJlYWNoZXMgNDUrIHNlY29uZHMpLiBFdmUBMAEBAQE- X-Mailer: YahooMailWebService/0.8.163.597 References: <16690513.cUljA3p6su@shu> Message-ID: <1383835200.12074.YahooMailNeo@web162905.mail.bf1.yahoo.com> Date: Thu, 7 Nov 2013 06:40:00 -0800 (PST) From: Kevin Grittner Reply-To: Kevin Grittner Subject: Re: Occasional spike in query response time (jumps from 200ms to 45 seconds) To: Robert Voinea , "pgsql-admin@postgresql.org" In-Reply-To: <16690513.cUljA3p6su@shu> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org Robert Voinea wrote: > From time to time (1-2 months) one of the production systems I > manage starts acting crazy... and this is starting to become a > problem. > > Every query I send to the server has a very long running time > (sometimes it reaches 45+ seconds). Even the simples queries like > "SELECT NOW()" run in 4-5 seconds... or more. > > This goes on for a few minutes. After that, everything is back to > normal. A likely cause for this is transparent huge page defrag.=A0 If you run `vmstat 1` during an episode and see a lot of system CPU time, that tends to confirm this.=A0 If you run `perf top` during an episode and see the kernel spending a lot of time in spinlock functions, that pretty much nails it.=A0 You might want to turn off transparent huge page support. > I'm guessing that, somehow, there is heavy I/O usage at that time Which might be another possibility if the `vmstat 1` shows a lot of I/O wait time. > I've seen that postgres 9.1.8 Changelog contains some bug fixes > related to performance of autovaccum: > > // BEGIN QUOTE > Fix performance problems with autovacuum truncation in busy > workloads (Jan Wieck) > > Truncation of empty pages at the end of a table requires > exclusive lock, but autovacuum was coded to fail (and release the > table lock) when there are conflicting lock requests. Under load, > it is easily possible that truncation would never occur, > resulting in table bloat. Fix by performing a partial truncation, > releasing the lock, then attempting to re-acquire the lock and > continue. This fix also greatly reduces the average time before > autovacuum releases the lock after a conflicting request arrives. > > Fix error in vacuum_freeze_table_age implementation (Andres > Freund) > > In installations that have existed for more than > vacuum_freeze_min_age transactions, this mistake prevented > autovacuum from using partial-table scans, so that a full-table > scan would always happen instead. > // END QUOTE If there is high I/O and you see autovacuum running wraparound prevention vacuums or vacuuming tables which have recently had a large number of rows deleted, you might solve the problem by updating.=A0 I would strongly recommend updating anyway, because otherwise you are running with known bugs and security vulnerabilities, including one very serious one. Why knowingly put yourself through dealing with bugs that others have already encountered, reported, diagnosed, and fixed? http://www.postgresql.org/support/versioning/ http://www.postgresql.org/support/security/faq/2013-04-04/ Note that in PostgreSQL, a minor release does not contain any new features or behavior changes except those deemed to be clear bugs. -- Kevin Grittner EDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company --=20 Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin