Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 14EDCB5DCEF for ; Tue, 12 Jul 2011 19:36:58 -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 90939-08 for ; Tue, 12 Jul 2011 22:36:52 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from nm2-vm0.bullet.mail.ne1.yahoo.com (nm2-vm0.bullet.mail.ne1.yahoo.com [98.138.91.39]) by mail.postgresql.org (Postfix) with SMTP id 7C574B5D944 for ; Tue, 12 Jul 2011 19:36:51 -0300 (ADT) Received: from [98.138.90.51] by nm2.bullet.mail.ne1.yahoo.com with NNFMP; 12 Jul 2011 22:36:49 -0000 Received: from [98.138.84.44] by tm4.bullet.mail.ne1.yahoo.com with NNFMP; 12 Jul 2011 22:36:49 -0000 Received: from [127.0.0.1] by smtp112.mail.ne1.yahoo.com with NNFMP; 12 Jul 2011 22:36:49 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1310510209; bh=B9REkr74e1cOW+Yr4Ia4xJtGlyhQZvH6tXQHjzCLX+s=; h=X-Yahoo-Newman-Id:Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=uEBZe2f771g3F9M8Ycjb29qQ7OeUn0pEzgwpa9t53D3b7jBCtUg/y7yJAziQNprzLSkxQ8suyDk6bYPFlE5BSH/D5tJEqbbPoUzA+FNbRdrk0lfqGS2KS/Eroxdabtp5QwnoFOf5HRcFRC7ORAo7W/FrQ0SrqGzpvf/jyeO2YQ8= X-Yahoo-Newman-Id: 536773.31995.bm@smtp112.mail.ne1.yahoo.com Received: from [192.168.206.5] (lhofhansl@67.170.234.149 with plain) by smtp112.mail.ne1.yahoo.com with SMTP; 12 Jul 2011 15:36:49 -0700 PDT X-Yahoo-SMTP: YmezqLWswBDx0ai534H100MJuqGzDQ-- X-YMail-OSG: 28khvDYVM1l1yGh88kPoPeC4_klkFjuV_DGUQcvNqGMfQNu uGHGnSp.X_j63igcX5xSanTs1uMcjg3iaqGQW7RdqiBhUbeMOrEtTOIRltvb 6jxBVVFlGRFXS8NltDkZ9NBCONIR1L8ZTZxGjE0.SXEfDAtJTBBnbc2fDwGd L57rYPR17EZ.QmGNaHIMw14JjJAhIw7PmoVa3_THy2e_v6l5aKyYPPRwSrzN 8wiPriXgvbKms8cFD67m7sPB5OAddxJPj8WTuevpwsBgW53S2d6jpZeJ_Sba Bw28LzbanjKhM0YbAMm_Sdb9bvUoCVYjuUdkO2V.06miXKiFK5TSFWpikfAd j5ATd.syCeVPkqda7okC2aw-- X-Yahoo-Newman-Property: ymail-3 Message-ID: <4E1CCC64.60700@yahoo.com> Date: Tue, 12 Jul 2011 15:36:20 -0700 From: lars User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110621 Fedora/3.1.11-1.fc14 Thunderbird/3.1.11 MIME-Version: 1.0 To: Kevin Grittner CC: Ivan Voras , pgsql-performance@postgresql.org Subject: Re: UPDATEDs slowing SELECTs in a fully cached database References: <4E16479D.3050605@yahoo.com> <4E1A0CBC.6090009@yahoo.com> <4E1A31AB.9010201@postnewspapers.com.au> <1310359653.80687.YahooMailRC@web121705.mail.ne1.yahoo.com> <4E1AEDAB020000250003F1C3@gw.wicourts.gov> <4E1B41EA.90104@yahoo.com> <4E1B05CC020000250003F1E6@gw.wicourts.gov> <4E1B810D.4070404@yahoo.com> <4E1B90AF.1020408@yahoo.com> <4E1C9A05.7060005@yahoo.com> <4E1C5563020000250003F252@gw.wicourts.gov> <4E1CA8E9.6090108@yahoo.com> <4E1CB56E.7080801@yahoo.com> <4E1C7B78020000250003F26E@gw.wicourts.gov> In-Reply-To: <4E1C7B78020000250003F26E@gw.wicourts.gov> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.909 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201107/125 X-Sequence-Number: 44337 On 07/12/2011 02:51 PM, Kevin Grittner wrote: > I ran x a bunch of times to get a baseline, then y once, then x a > bunch more times. The results were a bit surprising: > > cir=> \timing > Timing is on. > cir=> execute x('000000000000001','2011-6-30'); > count > ------- > 3456 > (1 row) > > Time: 9.823 ms > cir=> execute x('000000000000001','2011-6-30'); > count > ------- > 3456 > (1 row) > > Time: 8.481 ms > cir=> execute x('000000000000001','2011-6-30'); > count > ------- > 3456 > (1 row) > > Time: 14.054 ms > cir=> execute x('000000000000001','2011-6-30'); > count > ------- > 3456 > (1 row) > > Time: 10.169 ms > cir=> execute y('000000000000001', '000000000000001','2011-6-30'); > UPDATE 3456 > Time: 404.244 ms > cir=> execute x('000000000000001','2011-6-30'); > count > ------- > 3456 > (1 row) > > Time: 128.643 ms > cir=> execute x('000000000000001','2011-6-30'); > count > ------- > 3456 > (1 row) > > Time: 2.657 ms > cir=> execute x('000000000000001','2011-6-30'); > count > ------- > 3456 > (1 row) > > Time: 5.883 ms > cir=> execute x('000000000000001','2011-6-30'); > count > ------- > 3456 > (1 row) > > Time: 2.645 ms > cir=> execute x('000000000000001','2011-6-30'); > count > ------- > 3456 > (1 row) > > Time: 2.753 ms > cir=> execute x('000000000000001','2011-6-30'); > count > ------- > 3456 > (1 row) > > Time: 2.253 ms > Interesting. When you did you test, did you also find WAL write activity when running x the first time after y? (It's very hard to catch in only a single query, though). > Running the update made the next SELECT slow, then it was much > *faster*. My best guess is that the data landed in a more > concentrated set of pages after the update, and once autovacuum > kicked in and cleaned things up it was able to get to that set of > data faster. > >> autovacuum | off > Well, certainly not while under modification without running > autovacuum. That's disabling an integral part of what keeps > performance up. Oh, it's just switched off for testing, so that I can control when vacuum runs and make sure that it's not skewing the results while I am measuring something. In a real database I would probably err on vacuuming more than less. For a fully cached database I would probably want to switch off HOT pruning and compaction (which from what we see is done synchronously with the select) and leave it up to the asynchronous auto vacuum to do that. But maybe I am still not quite understanding the performance implications.