Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 99998B5DBF1 for ; Tue, 12 Jul 2011 17:05:34 -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 53487-08 for ; Tue, 12 Jul 2011 20:05:28 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from nm2-vm2.bullet.mail.ne1.yahoo.com (nm2-vm2.bullet.mail.ne1.yahoo.com [98.138.91.18]) by mail.postgresql.org (Postfix) with SMTP id 0AE7EB5DBF6 for ; Tue, 12 Jul 2011 17:05:27 -0300 (ADT) Received: from [98.138.90.54] by nm2.bullet.mail.ne1.yahoo.com with NNFMP; 12 Jul 2011 20:05:27 -0000 Received: from [98.138.226.60] by tm7.bullet.mail.ne1.yahoo.com with NNFMP; 12 Jul 2011 20:05:26 -0000 Received: from [127.0.0.1] by smtp211.mail.ne1.yahoo.com with NNFMP; 12 Jul 2011 20:05:26 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1310501126; bh=O74ZmBya+y5G7AapOu5aU8SDpG4h8npZEy/+N0frYRE=; 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=xfswr+El1GekyiQhbBWdhDSuZ1E4in/X/t4cL1u1hR5j/nqpVZGQOaqw/zkcQtpQzY4ocrZ2wU5JdbdPtRj7mhT8ZmZncDWR+53RujeiYcp3BiBajyWTPuqH3SLEkrdM2VoAb33sQpa9G60uIgPp6RO5yWt1iK3cDOfcQKGVNcs= X-Yahoo-Newman-Id: 965480.51338.bm@smtp211.mail.ne1.yahoo.com Received: from [192.168.206.5] (lhofhansl@67.170.234.149 with plain) by smtp211.mail.ne1.yahoo.com with SMTP; 12 Jul 2011 13:05:26 -0700 PDT X-Yahoo-SMTP: YmezqLWswBDx0ai534H100MJuqGzDQ-- X-YMail-OSG: aeQFgIQVM1m8W56onnWNGIQxMhyEeqMyOI3txyUDNO_Cga7 WOhYdPyvsSswvry5ARRFUeAhuB6MKevCSWwIePXpJ_T2kTL1yp4P2O9cxRQL Pt3O6tY7DIo1xrULiJDk.2WmmbBbEUfqoDZWEqPagt3joMH5DX5m5ggYiHgs 5Hcc1PYUyxmfub2v_DS0c3e0C.IQr32tiAR2ZrdQC.paXzixHdYitOrQ3LvG MNh2qIR3ilsr9L6k0TurDA04KIZepH.7VoFPCarcs9lkvjzwIW.rY1TsiVY7 nnp5gnTO7qtetrh9e0Tf.tz.IsczNHPiYtlumtX9iZlU1P.8Bye7nTdy6rKq _GJa_7Lfx8VkaWt4mCBcRoQ-- X-Yahoo-Newman-Property: ymail-3 Message-ID: <4E1CA8E9.6090108@yahoo.com> Date: Tue, 12 Jul 2011 13:04:57 -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> In-Reply-To: <4E1C5563020000250003F252@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/119 X-Sequence-Number: 44331 On 07/12/2011 12:08 PM, Kevin Grittner wrote: > lars wrote: > >> select count(*) from test where tenant = $1 and created_date = $2 > > Ah, that might be a major clue -- prepared statements. > > What sort of a plan do you get for that as a prepared statement? > (Note, it is very likely *not* to be the same plan as you get if you > run with literal values!) It is not at all unlikely that it could > resort to a table scan if you have one tenant which is five or ten > percent of the table, which would likely trigger the pruning as it > passed over the modified pages. > > -Kevin So a read of a row *will* trigger dead tuple pruning, and that requires WAL logging, and this is known/expected? This is actually the only answer I am looking for. :) I have not seen this documented anywhere. I know that Postgres will generate general plans for prepared statements (how could it do otherwise?), I also know that it sometimes chooses a sequential scan. This can always be tweaked to touch fewer rows and/or use a different plan. That's not my objective, though! The fact that a select (maybe a big analytical query we'll run) touching many rows will update the WAL and wait (apparently) for that IO to complete is making a fully cached database far less useful. I just artificially created this scenario. ... Just dropped the table to test something so I can't get the plan right now. Will send an update as soon as I get it setup again. Thanks again. -- Lars