Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 09294B5DBBE for ; Fri, 29 Jul 2011 12:57:46 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 27038-02 for ; Fri, 29 Jul 2011 15:57:39 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from nm8-vm0.bullet.mail.ne1.yahoo.com (nm8-vm0.bullet.mail.ne1.yahoo.com [98.138.91.23]) by mail.postgresql.org (Postfix) with SMTP id 38AA3B5D91F for ; Fri, 29 Jul 2011 12:57:39 -0300 (ADT) Received: from [98.138.90.55] by nm8.bullet.mail.ne1.yahoo.com with NNFMP; 29 Jul 2011 15:57:38 -0000 Received: from [98.138.87.11] by tm8.bullet.mail.ne1.yahoo.com with NNFMP; 29 Jul 2011 15:57:38 -0000 Received: from [127.0.0.1] by omp1011.mail.ne1.yahoo.com with NNFMP; 29 Jul 2011 15:57:38 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 175314.49819.bm@omp1011.mail.ne1.yahoo.com Received: (qmail 48141 invoked by uid 60001); 29 Jul 2011 15:57:38 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1311955057; bh=Mqi/pANmcWov/Ye1U0s3hO4LDUWzbFXh+p/ngF5n254=; h=X-YMail-OSG:Received:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=TDvuV9K/A0hVWEfS0cvLmSCVHu2vywDnmWzp/9Wv/GjXnsx5WfNqzugzqpsbFHyxRTQJR7/TQ4MhSXDW67BipGAxN8pDBYq5JhHFKPAqEvIFVa7XyQjEc2DDaoQ1+KCypJDRm20iZTuFyEyDwZZ6YNHvnqagGebFE01Lj1SZqLo= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=LWuKczwN/SL9yiTpyXwDg9MR/W9C3gC/Eig5wKAx6qNONcNkjM2irTMLcqYbu/NBG/gCzj+vFxXUtiBZ2mjAGfLSE29f1wyVIo05f5gUMgECSHT5Q27UbUOCt7e9IlMwof6R7CbHWNKlm/566e1ot04I3GEdOtbH5tHXbNttY+s=; X-YMail-OSG: 1lsKx7EVM1lVRTcHED.bHk9pmFnkm4x5LB8Tbiyx64cSozg IHKyBRPHSni7RFsbsapP_Gf33MbDG9OtetaLt7giuCM5SmSv9D19UExjzLrZ 7h0ehdfk78ENAKE7fHlT1S9PGR.o3fbXQNI4edPnbqBJFUH3xBBiBMUOmZdA mPe9WrtMMNOCrE6oFntC1lEmkPOcG28rV6pp5Wi.Hcrnj.Qxj1OXFVlmeYVm NqvAH5yraJhS8MErG1EREToFxCgyLqfPMEqOWXxrCO7Aq1RFKcbJ.l5025ab 7UP1bkFquxkqJvu0SGkDuOiqhEhUUhGOrGMRdbmDjXznDaivHxktZb_DRx4x 44vFN8MwnPhsGl66Y03os3fST0nXdRG3aYp71cT7V4dBmA9h5jafpcMEeqDP 7r1TLUrKF9xs1cyLDszkWJW6yrN3Uwi19c.5UIFEPdPsSfGJV48RUUlaMXCE CW3LIRKc- Received: from [67.170.234.149] by web121713.mail.ne1.yahoo.com via HTTP; Fri, 29 Jul 2011 08:57:37 PDT X-Mailer: YahooMailWebService/0.8.112.310352 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> <4E1CD580.3030100@yahoo.com> Message-ID: <1311955057.37123.YahooMailNeo@web121713.mail.ne1.yahoo.com> Date: Fri, 29 Jul 2011 08:57:37 -0700 (PDT) From: lars hofhansl Reply-To: lars hofhansl Subject: Re: UPDATEDs slowing SELECTs in a fully cached database To: Pavan Deolasee , Merlin Moncure Cc: Kevin Grittner , Ivan Voras , "pgsql-performance@postgresql.org" In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-3.091 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RP_MATCHES_RCVD=-1.192 X-Spam-Level: X-Archive-Number: 201107/225 X-Sequence-Number: 44437 Thanks Pavan!=0A=0A=0AI think the most important points are still that:=0A1= . The WAL write should be happening asynchronously (if that is possible)=0A= 2. There should be an option do not perform these compactions if the page i= s only touched by reads.=0A=0A(Assuming that when most of the databaseresid= es in the cache these optimizations are less important.)=0A=0A=0A-- Lars=0A= =0A=0A----- Original Message -----=0AFrom: Pavan Deolasee =0ATo: Merlin Moncure =0ACc: lars ; Kevin Grittner ; Ivan Voras ; pgsql-performance@postgresql.org=0ASent: Wednesday, July 27,= 2011 7:15 AM=0ASubject: Re: [PERFORM] UPDATEDs slowing SELECTs in a fully = cached database=0A=0AOn Wed, Jul 13, 2011 at 10:52 AM, Merlin Moncure wrote:=0A...=0A=0AThere are couple of other (very important= ) things that HOT does, but=0Aprobably its not advertised a lot. Even for n= on-HOT updates (which=0Ameans either indexed columns were changed or page r= an out of free=0Aspace) or deletes, HOT prunes those tuples and instead mar= k the line=0Apointer as DEAD. The page is defragmented and dead space is re= covered.=0AEach such dead tuple now only consumes two bytes in the page unt= il=0Avacuum removes the dead line pointers. Thats the reason why OP is=0Ase= eing the behavior even when index columns are being updated.=0A=0AWe made a= few adjustments to ensure that a page is not pruned too=0Aearly. So we tra= ck the oldest XID that did any updates/deletes to the=0Apage and attempt pr= uning only when the RecentXmin is past the XID. We=0Aalso mark the page as = "full" if some previous update did not find=0Aenough free space to do in-bl= ock update and use that hint to decide if=0Awe should attempt to prune the = page. Finally, we prune only if we get=0Athe cleanup lock without blocking.= =0A=0AWhat might be worth looking at this condition in pruneheap.c:=0A=0A/*= =0A=A0 =A0 * We prune when a previous UPDATE failed to find enough space o= n the page=0A=A0 =A0 * for a new tuple version, or when free space falls b= elow the relation's=0A=A0 =A0 * fill-factor target (but not less than 10%)= .=0A=A0 =A0 *=0A=A0 =A0 * Checking free space here is questionable since = we aren't holding any=0A=A0 =A0 * lock on the buffer; in the worst case we= could get a bogus answer. It's=0A=A0 =A0 * unlikely to be *seriously* wro= ng, though, since reading either pd_lower=0A=A0 =A0 * or pd_upper is proba= bly atomic.=A0 Avoiding taking a lock seems more=0A=A0 =A0 * important tha= n sometimes getting a wrong answer in what is after all=0A=A0 =A0 * just a= heuristic estimate.=0A=A0 =A0 */=0A=A0 =A0 minfree =3D RelationGetTargetP= ageFreeSpace(relation,=0A=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 HEAP_DEFAULT_FILLFACTOR);=0A=A0 = =A0 minfree =3D Max(minfree, BLCKSZ / 10);=0A=0A=A0 =A0 if (PageIsFull(page= ) || PageGetHeapFreeSpace(page) < minfree)=0A=A0 =A0 {=0A=0A=0ASo if the fr= ee space in a page falls below the fill-factor or 10% of=0Athe block size, = we would try to prune the page. We probably need to=0Arevisit this area and= see if we need to tune HOT ever better. One=0Aoption could be to see how m= uch space we are going to free and carry=0Aout the operation only if its si= gnificant enough to justify the cost.=0A=0AI know we had done several bench= marking tests while HOT development,=0Abut the tuning mechanism still may n= ot be perfect for all kinds of=0Awork loads and it would probably never be.= =0A=0AThanks,=0APavan=0A=0A-- =0APavan Deolasee=0AEnterpriseDB=A0 =A0=A0 ht= tp://www.enterprisedb.com=0A