Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 332462E035C for ; Mon, 17 Dec 2007 11:46:15 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 38787-04 for ; Mon, 17 Dec 2007 11:45:59 -0400 (AST) Received: from gwmta.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) by postgresql.org (Postfix) with ESMTP id 433EB2E0080 for ; Mon, 17 Dec 2007 11:46:07 -0400 (AST) Received: from Courts-MTA by gwmta.wicourts.gov with Novell_GroupWise; Mon, 17 Dec 2007 09:46:02 -0600 Message-Id: <47664546.EE98.0025.0@wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 7.0.2 Date: Mon, 17 Dec 2007 09:45:43 -0600 From: "Kevin Grittner" To: "Tom Lane" Cc: Subject: Re: VACUUM FREEZE output more than double input References: <47626534.EE98.0025.0@wicourts.gov><47626534.EE98.0025.0@wicourts.gov> <15401.1197676791@sss.pgh.pa.us> In-Reply-To: <15401.1197676791@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/257 X-Sequence-Number: 28073 >>> On Fri, Dec 14, 2007 at 5:59 PM, in message <15401.1197676791@sss.pgh.= pa.us>, Tom Lane wrote:=20 > "Kevin Grittner" writes: >> Why double writes per read, plus massive writes at checkpoint? >=20 > The double writes aren't surprising: freezing has to be WAL-logged, > and the odds are that each page hasn't been touched since the last > checkpoint, so the WAL log will include a complete page image. > So in the steady state where all shared buffers are dirty, the > per-page cycle is: > * write out a dirty buffer so it can be reclaimed > * read in a page > * modify it to mark tuples frozen > * write an image of the page to WAL > * leave the now-dirty page in shared buffers for later writing >=20 > The checkpoint spikes would come from trying to flush out all the > dirty buffers at once. =20 Got it. Thanks. =20 > You'd expect a bit of a valley after each peak, since the vacuum > could presumably recycle some buffers without having to flush 'em > first; but I don't see one in your data. That may just be because > the numbers are too noisy, but I kinda suspect that the vacuum is > dirtying buffers nearly as fast as the bgwriter can clean them, > leaving not a lot of daylight for a valley. =20 Yeah, the pattern was pretty consistent and without valleys. =20 > 8.3 should pretty well eliminate the checkpoint spike in this scenario, > because vacuum will work in a limited number of shared buffers instead > of dirtying the whole cache. But you'll still see 2X writes over reads. =20 Testing 8.3beta4 so far has shown both smoother I/O and better performance in all respects. The preliminary post I did where I thought I saw some regression on loading a pg_dump turned out to be was an "apples to oranges" comparison; comparing the same load on the same hardware and OS, 8.3 wins. (Kudos to all who worked on these improvements!) =20 > If this is data that you could re-generate at need, it might make sense > to turn off full_page_writes during the initial data load and vacuum. =20 Thanks for the suggestions; I'll try that. =20 > I concur with trying to FREEZE all the data while you do this, else > you'll see the same work done whenever the data happens to slip past > the auto freeze threshold. =20 Thanks. I thought that made sense, but I'm still trying to get my head around some of the dynamics of PostgreSQL and MVCC. I'll suggest that as policy here. =20 -Kevin =20