From deck1@yahoo.com Wed May 14 20:11:34 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id C06A52E00C0 for ; Wed, 14 May 2008 17:11:34 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 17165-01-4 for ; Wed, 14 May 2008 17:11:27 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from n75.bullet.mail.sp1.yahoo.com (n75.bullet.mail.sp1.yahoo.com [98.136.44.51]) by developer.postgresql.org (Postfix) with SMTP id 59ED92E0065 for ; Wed, 14 May 2008 17:09:52 -0300 (ADT) Received: from [216.252.122.217] by n75.bullet.mail.sp1.yahoo.com with NNFMP; 14 May 2008 20:09:49 -0000 Received: from [69.147.84.100] by t2.bullet.sp1.yahoo.com with NNFMP; 14 May 2008 20:09:49 -0000 Received: from [127.0.0.1] by omp201.mail.sp1.yahoo.com with NNFMP; 14 May 2008 20:09:49 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 29948.45377.bm@omp201.mail.sp1.yahoo.com Received: (qmail 71723 invoked by uid 60001); 14 May 2008 20:09:48 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Received:X-Mailer:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type:Message-ID; b=59GkvRVltbpDjdLIUpvC10dBcTCEWa+6h2gd8VVAYpwkpjF9cup5bCAZUVoi+Z1jvY6MkbxmrY8+Tft+OCqgml9bc467jSnpvrodAIJUKMwbXQbC7rj+C7U1ZmjhW8iXn46URxFiRiYmbQTLal/l9slFacxakDN/Y5+9cJNCZLE=; Received: from [66.39.195.151] by web44808.mail.sp1.yahoo.com via HTTP; Wed, 14 May 2008 13:09:48 PDT X-Mailer: YahooMailRC/975.38 YahooMailWebService/0.7.199 Date: Wed, 14 May 2008 13:09:48 -0700 (PDT) From: Doug Eck Reply-To: Doug Eck Subject: I/O on select count(*) To: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1708251028-1210795788=:71690" Message-ID: <920841.71690.qm@web44808.mail.sp1.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200805/183 X-Sequence-Number: 30151 --0-1708251028-1210795788=:71690 Content-Type: text/plain; charset=us-ascii I have a large table (~ 2B rows) that contains an indexed timestamp column. I am attempting to run a query to determine the number of rows for a given day using something like "select count(*) from tbl1 where ts between '2008-05-12 00:00:00.000' and '2008-05-12 23:59:59.999'". Explain tells me that the query will be done using an index scan (as I would expect), and I realize that it is going to take a while. My question concerns some unusual I/O activity on the box (SUSE) when I run the query. For the first couple of minutes I see reads only. After that vmstat shows mixed reads and writes in a ratio of about 1 block read to 5 blocks written. We have determined that files in our data and log partitions are being hit, but the file system itself is not growing during this time (it appears to be writing over the same chunk of space over and over again). Memory on the box is not being swapped while all of this is happening. I would have guessed that a "select count(*)" would not require a bunch of writes, and I can't begin to figure out why the number of blocks written are so much higher than the blocks read. If I modify the where clause to only count the rows for a given minute or two, I see the reads but I never see the unusual write behavior. Any thoughts into what could be going on? Thanks in advance for your help. Doug --0-1708251028-1210795788=:71690 Content-Type: text/html; charset=us-ascii
I have a large table (~ 2B rows) that contains an indexed timestamp column.  I am attempting to run a query to determine the number of rows for a given day using something like "select count(*) from tbl1 where ts between '2008-05-12 00:00:00.000' and '2008-05-12 23:59:59.999'".  Explain tells me that the query will be done using an index scan (as I would expect), and I realize that it is going to take a while.  My question concerns some unusual I/O activity on the box (SUSE)  when I run the query.

For the first couple of minutes I see reads only.  After that vmstat shows mixed reads and writes in a ratio of about 1 block read to 5 blocks written.  We have determined that files in our data and log partitions are being hit, but the file system itself is not growing during this time (it appears to be writing over the same chunk of space over and over again).  Memory on the box is not being swapped while all of this is happening.  I would have guessed that a "select count(*)" would not require a bunch of writes, and I can't begin to figure out why the number of blocks written are so much higher than the blocks read.  If I modify the where clause to only count the rows for a given minute or two, I see the reads but I never see the unusual write behavior.

Any thoughts into what could be going on?  Thanks in advance for your help.

Doug

--0-1708251028-1210795788=:71690-- From mmoncure@gmail.com Wed May 14 20:38:36 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 730DC2E004A for ; Wed, 14 May 2008 17:38:36 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 30344-02 for ; Wed, 14 May 2008 17:38:24 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.155]) by developer.postgresql.org (Postfix) with ESMTP id 8FFD52E0086 for ; Wed, 14 May 2008 17:38:25 -0300 (ADT) Received: by fg-out-1718.google.com with SMTP id 16so87504fgg.23 for ; Wed, 14 May 2008 13:38:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=H2AkeNdtIzCm38N6D1XUEXMddHGHWZVNl6gMvW4mHsM=; b=IUbshcvneiQvnfHlGSdBqKy5dZ8pdv1UZGKEmMTmkc0IpoaihXHSutPZc8xKQAu5uW0CegUDsTcihRLivS9qUpwS3Hxg3O5VPRnBwW/CNud3rAcNW56VQwl99c7WTrkV+Gb5kVlSJzJPrj83C6RtZEpwrJxgxspq8R0e54x5yBk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=ifM1lGiL4Sk0iPuzBko+WLYV4zuFqOrNDlPhyjSqWW/oDbuuhe0QZMo6TSzUGijiBiLxxW0KvNO1rWjQiMXBxAUYit1uwHMvDnyAgg2wIq9A6AJEh/t/F2C2P0IpzCLWaQxtnPJN06urWARQIIh8p+HKOOrI6Z58/sTGSUnW3H8= Received: by 10.82.127.14 with SMTP id z14mr236722buc.67.1210797503772; Wed, 14 May 2008 13:38:23 -0700 (PDT) Received: by 10.82.145.1 with HTTP; Wed, 14 May 2008 13:38:23 -0700 (PDT) Message-ID: Date: Wed, 14 May 2008 16:38:23 -0400 From: "Merlin Moncure" To: "Doug Eck" Subject: Re: I/O on select count(*) Cc: pgsql-performance@postgresql.org In-Reply-To: <920841.71690.qm@web44808.mail.sp1.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/184 X-Sequence-Number: 30152 On Wed, May 14, 2008 at 4:09 PM, Doug Eck wrote: > I have a large table (~ 2B rows) that contains an indexed timestamp column. > I am attempting to run a query to determine the number of rows for a given > day using something like "select count(*) from tbl1 where ts between > '2008-05-12 00:00:00.000' and '2008-05-12 23:59:59.999'". Explain tells me > that the query will be done using an index scan (as I would expect), and I > realize that it is going to take a while. My question concerns some unusual > I/O activity on the box (SUSE) when I run the query. > > For the first couple of minutes I see reads only. After that vmstat shows > mixed reads and writes in a ratio of about 1 block read to 5 blocks > written. We have determined that files in our data and log partitions are > being hit, but the file system itself is not growing during this time (it > appears to be writing over the same chunk of space over and over again). > Memory on the box is not being swapped while all of this is happening. I > would have guessed that a "select count(*)" would not require a bunch of > writes, and I can't begin to figure out why the number of blocks written are > so much higher than the blocks read. If I modify the where clause to only > count the rows for a given minute or two, I see the reads but I never see > the unusual write behavior. > > Any thoughts into what could be going on? Thanks in advance for your help. can you post the exact output of explain analyze? (or, at least, explain if the query takes too long) merlin From deck1@yahoo.com Wed May 14 21:23:55 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 9737A2E0052 for ; Wed, 14 May 2008 18:23:55 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 55411-05 for ; Wed, 14 May 2008 18:23:48 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from n66.bullet.mail.sp1.yahoo.com (n66.bullet.mail.sp1.yahoo.com [98.136.44.50]) by developer.postgresql.org (Postfix) with SMTP id 7F35A2E0050 for ; Wed, 14 May 2008 18:23:51 -0300 (ADT) Received: from [216.252.122.218] by n66.bullet.mail.sp1.yahoo.com with NNFMP; 14 May 2008 21:23:50 -0000 Received: from [69.147.65.168] by t3.bullet.sp1.yahoo.com with NNFMP; 14 May 2008 21:23:50 -0000 Received: from [127.0.0.1] by omp503.mail.sp1.yahoo.com with NNFMP; 14 May 2008 21:23:50 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 97197.68829.bm@omp503.mail.sp1.yahoo.com Received: (qmail 86106 invoked by uid 60001); 14 May 2008 21:23:49 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Received:X-Mailer:Date:From:Reply-To:Subject:To:Cc:MIME-Version:Content-Type:Message-ID; b=YH/vsAaf1zLZCC9LrolNtVufNOkQuAPaOVAasaGSpjKnFcYpM1SP3K/kJ69YM7jdmm/3cgAx3IckQs4NvgYzhOaNakbfv5xP4QYjywilsfa3uABPwpJBxbRLRrWhle31LrGuRr0zFTjufEAJUG0Ix744FxSu6OPY4MIIKOhJFRY=; Received: from [66.39.195.151] by web44806.mail.sp1.yahoo.com via HTTP; Wed, 14 May 2008 14:23:49 PDT X-Mailer: YahooMailRC/975.38 YahooMailWebService/0.7.199 Date: Wed, 14 May 2008 14:23:49 -0700 (PDT) From: Doug Eck Reply-To: Doug Eck Subject: Re: I/O on select count(*) To: Merlin Moncure Cc: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-687963745-1210800229=:85729" Message-ID: <811584.85729.qm@web44806.mail.sp1.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200805/185 X-Sequence-Number: 30153 --0-687963745-1210800229=:85729 Content-Type: text/plain; charset=us-ascii ----- Original Message ---- From: Merlin Moncure To: Doug Eck Cc: pgsql-performance@postgresql.org Sent: Wednesday, May 14, 2008 3:38:23 PM Subject: Re: [PERFORM] I/O on select count(*) On Wed, May 14, 2008 at 4:09 PM, Doug Eck wrote: > I have a large table (~ 2B rows) that contains an indexed timestamp column. > I am attempting to run a query to determine the number of rows for a given > day using something like "select count(*) from tbl1 where ts between > '2008-05-12 00:00:00.000' and '2008-05-12 23:59:59.999'". Explain tells me > that the query will be done using an index scan (as I would expect), and I > realize that it is going to take a while. My question concerns some unusual > I/O activity on the box (SUSE) when I run the query. > > For the first couple of minutes I see reads only. After that vmstat shows > mixed reads and writes in a ratio of about 1 block read to 5 blocks > written. We have determined that files in our data and log partitions are > being hit, but the file system itself is not growing during this time (it > appears to be writing over the same chunk of space over and over again). > Memory on the box is not being swapped while all of this is happening. I > would have guessed that a "select count(*)" would not require a bunch of > writes, and I can't begin to figure out why the number of blocks written are > so much higher than the blocks read. If I modify the where clause to only > count the rows for a given minute or two, I see the reads but I never see > the unusual write behavior. > > Any thoughts into what could be going on? Thanks in advance for your help. can you post the exact output of explain analyze? (or, at least, explain if the query takes too long) merlin The query takes a long time to run, so I'll start with the explain output. I can run explain analyze (given enough time) if you believe its output could hold some clues. db_2008=> explain select count(*) from ot_2008_05 where transact_time between '2008-05-12 00:00:00.000' and '2008-05-12 23:59:59.999'; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=10368613.47..10368613.48 rows=1 width=0) -> Index Scan using ot_2008_05_ak2 on ot_2008_05 (cost=0.00..10011333.27 rows=142912078 width=0) Index Cond: ((transact_time >= '2008-05-12 00:00:00-04'::timestamp with time zone) AND (transact_time <= '2008-05-12 23:59:59.999-04'::timestamp with time zone)) (3 rows) db_2008=> Doug --0-687963745-1210800229=:85729 Content-Type: text/html; charset=us-ascii


----- Original Message ----
From: Merlin Moncure <mmoncure@gmail.com>
To: Doug Eck <deck1@yahoo.com>
Cc: pgsql-performance@postgresql.org
Sent: Wednesday, May 14, 2008 3:38:23 PM
Subject: Re: [PERFORM] I/O on select count(*)

On Wed, May 14, 2008 at 4:09 PM, Doug Eck <deck1@yahoo.com> wrote:
> I have a large table (~ 2B rows) that contains an indexed timestamp column.
> I am attempting to run a query to determine the number of rows for a given
> day using something like "select count(*) from tbl1 where ts between
> '2008-05-12 00:00:00.000' and '2008-05-12 23:59:59.999'".  Explain tells me
> that the query will be done using an index scan (as I would expect), and I
> realize that it is going to take a while.  My question concerns some unusual
> I/O activity on the box (SUSE)  when I run the query.
>
> For the first couple of minutes I see reads only.  After that vmstat shows
> mixed reads and writes in a ratio of about 1 block read to 5 blocks
> written.  We have determined that files in our data and log partitions are
> being hit, but the file system itself is not growing during this time (it
> appears to be writing over the same chunk of space over and over again).
> Memory on the box is not being swapped while all of this is happening.  I
> would have guessed that a "select count(*)" would not require a bunch of
> writes, and I can't begin to figure out why the number of blocks written are
> so much higher than the blocks read.  If I modify the where clause to only
> count the rows for a given minute or two, I see the reads but I never see
> the unusual write behavior.
>
> Any thoughts into what could be going on?  Thanks in advance for your help.

can you post the exact output of explain analyze? (or, at least,
explain if the query takes too long)

merlin

The query takes a long time to run, so I'll start with the explain output.  I can run explain analyze (given enough time) if you believe its output could hold some clues.

db_2008=> explain select count(*) from ot_2008_05 where transact_time between '2008-05-12 00:00:00.000' and '2008-05-12 23:59:59.999';
                                                                                QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Aggregate  (cost=10368613.47..10368613.48 rows=1 width=0)
   ->  Index Scan using ot_2008_05_ak2 on ot_2008_05  (cost=0.00..10011333.27 rows=142912078 width=0)
         Index Cond: ((transact_time >= '2008-05-12 00:00:00-04'::timestamp with time zone) AND (transact_time <= '2008-05-12 23:59:59.999-04'::timestamp with time zone))
(3 rows)

db_2008=>

Doug


--0-687963745-1210800229=:85729-- From Kevin.Grittner@wicourts.gov Wed May 14 22:11:32 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 7DE502E0031 for ; Wed, 14 May 2008 19:11:32 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 78660-05 for ; Wed, 14 May 2008 19:11:25 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from gwmta.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) by developer.postgresql.org (Postfix) with ESMTP id 2DBBC2E002D for ; Wed, 14 May 2008 19:11:29 -0300 (ADT) Received: from Courts-MTA by gwmta.wicourts.gov with Novell_GroupWise; Wed, 14 May 2008 17:11:27 -0500 Message-Id: <482B1D5F.EE98.0025.0@wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 7.0.3 Date: Wed, 14 May 2008 17:11:21 -0500 From: "Kevin Grittner" To: ,"Doug Eck" Subject: Re: I/O on select count(*) References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> In-Reply-To: <920841.71690.qm@web44808.mail.sp1.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/186 X-Sequence-Number: 30154 >>> Doug Eck wrote: > I am attempting to run a query to determine the number of rows for a given > day using something like "select count(*) from tbl1 where ts between > '2008-05-12 00:00:00.000' and '2008-05-12 23:59:59.999'". Explain tells me > that the query will be done using an index scan (as I would expect), and I > realize that it is going to take a while. My question concerns some unusual > I/O activity on the box (SUSE) when I run the query. > > For the first couple of minutes I see reads only. After that vmstat shows > mixed reads and writes in a ratio of about 1 block read to 5 blocks written. > Any thoughts into what could be going on? Thanks in advance for your help. Odd as it may seem, a SELECT can cause a page to be rewritten. If this is the first time that the rows are being read since they were inserted (or since the database was loaded, including from backup), it may be rewriting the rows to set hint bits, which can make subsequent access faster. The best solution may be to vacuum more often. http://archives.postgresql.org/pgsql-performance/2007-12/msg00206.php -Kevin From gsmith@gregsmith.com Thu May 15 01:40:10 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id A3CA52E008B for ; Wed, 14 May 2008 22:40:10 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 90108-02 for ; Wed, 14 May 2008 22:39:57 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from westnet.com (westnet.com [216.187.52.2]) by developer.postgresql.org (Postfix) with ESMTP id 8739E2E006D for ; Wed, 14 May 2008 22:40:01 -0300 (ADT) Received: from westnet.com (localhost [127.0.0.1]) by westnet.com (8.14.0/8.14.0) with ESMTP id m4F1e0BB001918 for ; Wed, 14 May 2008 21:40:00 -0400 (EDT) Received: from localhost (gsmith@localhost) by westnet.com (8.14.0/8.13.2/Submit) with ESMTP id m4F1e0rs001915 for ; Wed, 14 May 2008 21:40:00 -0400 (EDT) X-Authentication-Warning: westnet.com: gsmith owned process doing -bs Date: Wed, 14 May 2008 21:39:59 -0400 (EDT) From: Greg Smith X-X-Sender: gsmith@westnet.com To: pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) In-Reply-To: <482B1D5F.EE98.0025.0@wicourts.gov> Message-ID: References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/189 X-Sequence-Number: 30157 On Wed, 14 May 2008, Kevin Grittner wrote: > If this is the first time that the rows are being read since they were > inserted (or since the database was loaded, including from backup), it > may be rewriting the rows to set hint bits, which can make subsequent > access faster. This is the second time this has come up recently, and I know it used to puzzle me too. This is a particularly relevant area to document better for people doing benchmarking. As close I've found to a useful commentary on this subject is the thread at http://archives.postgresql.org/pgsql-patches/2005-07/msg00390.php I still don't completely understand this myself though, if I did I'd add a FAQ on it. Anyone want to lecture for a minute on the birth and care of hint bits? I'll make sure any comments here get onto the wiki. -- * Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD From alvherre@commandprompt.com Thu May 15 02:06:08 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 792EE2E008F for ; Wed, 14 May 2008 23:06:08 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 07327-10 for ; Wed, 14 May 2008 23:05:57 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from lists.commandprompt.com (host-159.commandprompt.net [207.173.203.159]) by developer.postgresql.org (Postfix) with ESMTP id 2A4762E008B for ; Wed, 14 May 2008 23:06:02 -0300 (ADT) Received: from perhan.alvh.no-ip.org (200-126-123-196.bk8-dsl.surnet.cl [200.126.123.196]) (authenticated bits=0) by lists.commandprompt.com (8.13.8/8.13.8) with ESMTP id m4F26vmr007828 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 14 May 2008 19:06:59 -0700 Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id D6F6D47C5E; Wed, 14 May 2008 22:05:53 -0400 (CLT) Date: Wed, 14 May 2008 22:05:53 -0400 From: Alvaro Herrera To: Greg Smith Cc: pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) Message-ID: <20080515020553.GN9838@alvh.no-ip.org> References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0 (lists.commandprompt.com [207.173.203.159]); Wed, 14 May 2008 19:07:01 -0700 (PDT) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/190 X-Sequence-Number: 30158 Greg Smith wrote: > On Wed, 14 May 2008, Kevin Grittner wrote: > >> If this is the first time that the rows are being read since they were >> inserted (or since the database was loaded, including from backup), it >> may be rewriting the rows to set hint bits, which can make subsequent >> access faster. > > This is the second time this has come up recently, and I know it used to > puzzle me too. This is a particularly relevant area to document better > for people doing benchmarking. As close I've found to a useful > commentary on this subject is the thread at > http://archives.postgresql.org/pgsql-patches/2005-07/msg00390.php > > I still don't completely understand this myself though, if I did I'd add > a FAQ on it. Anyone want to lecture for a minute on the birth and care > of hint bits? I'll make sure any comments here get onto the wiki. Hint bits are used to mark tuples as created and/or deleted by transactions that are know committed or aborted. To determine the visibility of a tuple without such bits set, you need to consult pg_clog and possibly pg_subtrans, so it is an expensive check. On the other hand, if the tuple has the bits set, then it's state is known (or, at worst, it can be calculated easily from your current snapshot, without looking at pg_clog.) There are four hint bits: XMIN_COMMITTED -- creating transaction is known committed XMIN_ABORTED -- creating transaction is known aborted XMAX_COMMITTED -- same, for the deleting transaction XMAX_ABORTED -- ditto If neither of the bits is set, then the transaction is either in progress (which you can check by examining the list of running transactions in shared memory) or your process is the first one to check (in which case, you need to consult pg_clog to know the status, and you can update the hint bits if you find out a permanent state). Regarding FAQs, I'm having trouble imagining putting this in the user FAQ; I think it belongs into the developer's FAQ. However, a benchmarker is not going to look there. Maybe we should start "a benchmarker's FAQ"? -- Alvaro Herrera http://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support From gsmith@gregsmith.com Thu May 15 02:21:53 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 331532E008D for ; Wed, 14 May 2008 23:21:53 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 17613-03 for ; Wed, 14 May 2008 23:21:41 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from westnet.com (westnet.com [216.187.52.2]) by developer.postgresql.org (Postfix) with ESMTP id D440D2E004A for ; Wed, 14 May 2008 23:21:47 -0300 (ADT) Received: from westnet.com (localhost [127.0.0.1]) by westnet.com (8.14.0/8.14.0) with ESMTP id m4F2Ljr9007138; Wed, 14 May 2008 22:21:45 -0400 (EDT) Received: from localhost (gsmith@localhost) by westnet.com (8.14.0/8.13.2/Submit) with ESMTP id m4F2LjbX007134; Wed, 14 May 2008 22:21:45 -0400 (EDT) X-Authentication-Warning: westnet.com: gsmith owned process doing -bs Date: Wed, 14 May 2008 22:21:45 -0400 (EDT) From: Greg Smith X-X-Sender: gsmith@westnet.com To: Alvaro Herrera cc: pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) In-Reply-To: <20080515020553.GN9838@alvh.no-ip.org> Message-ID: References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/191 X-Sequence-Number: 30159 On Wed, 14 May 2008, Alvaro Herrera wrote: > If neither of the bits is set, then the transaction is either in > progress (which you can check by examining the list of running > transactions in shared memory) or your process is the first one to check > (in which case, you need to consult pg_clog to know the status, and you > can update the hint bits if you find out a permanent state). So is vacuum helpful here because it will force all that to happen in one batch? To put that another way: if I've run a manual vacuum, is it true that it will have updated all the hint bits to XMIN_COMMITTED for all the tuples that were all done when the vacuum started? > Regarding FAQs, I'm having trouble imagining putting this in the user > FAQ; I think it belongs into the developer's FAQ. However, a > benchmarker is not going to look there. Maybe we should start "a > benchmarker's FAQ"? On the wiki I've started adding a series of things that are performance-related FAQs. There's three of them mixed in the bottom of http://wiki.postgresql.org/wiki/Frequently_Asked_Questions right now, about slow count(*) and dealing with slow queries. Here the FAQ would be "Why am I seeing all these writes when I'm just doing selects on my table?", and if it's mixed in with a lot of other performance related notes people should be able to find it. The answer and suggestions should be simple enough to be useful to a user who just noticed this behavior, while perhaps going into developer land for those who want to know more about the internals. -- * Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD From jdevisser@digitalfairway.com Thu May 15 02:38:14 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 4CF9D2E002D for ; Wed, 14 May 2008 23:38:14 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 27741-03 for ; Wed, 14 May 2008 23:38:04 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from wa-out-1112.google.com (wa-out-1112.google.com [209.85.146.182]) by developer.postgresql.org (Postfix) with ESMTP id 2724F2E003A for ; Wed, 14 May 2008 23:38:09 -0300 (ADT) Received: by wa-out-1112.google.com with SMTP id n4so253157wag.5 for ; Wed, 14 May 2008 19:38:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; bh=L5ga9Sbn8jFrWxNAPZHzjtKWoHaANzZnNQS8OEz9l7Q=; b=l1ixYpajvLKedMTUDEzR+vWh6beoRWKcAkEOIlwPyBkFJRJfDshxwhtUiK5OGMglAaBpr/5+BjEHN6AKkb/IUPFhYd1MeSnL11FOYZOMfv3HoTXWlwUWsZB2Ozlk44rlcoT05RXht/7R3Oz7zyyQmi9eex6UgmmcGXyBIH4iuMg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=HONnEAb41rzps5LXjsN1mPHKgBcGQswlzSDEYnvSppQg9hfRnV6yTrUkflBPFb2/thQgPQGtIKU8cYCqzXzl1MF2u1Bx0xCTmMPdRQYuba5XmzlvATxiuspCZryveoHINDIijs+r2p6SgGVIyIy/4FH73Ghh5YhqxMSEDGYZfQA= Received: by 10.114.153.18 with SMTP id a18mr1890079wae.127.1210819088541; Wed, 14 May 2008 19:38:08 -0700 (PDT) Received: by 10.115.92.16 with HTTP; Wed, 14 May 2008 19:38:08 -0700 (PDT) Message-ID: <1159c1e90805141938j5f85b490rb5c1cfdf9e428bce@mail.gmail.com> Date: Wed, 14 May 2008 22:38:08 -0400 From: "Jan de Visser" To: "Greg Smith" Subject: Re: I/O on select count(*) Cc: "Alvaro Herrera" , pgsql-performance@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> X-Google-Sender-Auth: 496724cf613df46b X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/192 X-Sequence-Number: 30160 On 5/14/08, Greg Smith wrote: > On Wed, 14 May 2008, Alvaro Herrera wrote: > > > > If neither of the bits is set, then the transaction is either in progress > (which you can check by examining the list of running transactions in shared > memory) or your process is the first one to check (in which case, you need > to consult pg_clog to know the status, and you can update the hint bits if > you find out a permanent state). > > > > So is vacuum helpful here because it will force all that to happen in one > batch? To put that another way: if I've run a manual vacuum, is it true > that it will have updated all the hint bits to XMIN_COMMITTED for all the > tuples that were all done when the vacuum started? From pavan.deolasee@gmail.com Thu May 15 02:41:02 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 70DAC2E0035 for ; Wed, 14 May 2008 23:41:02 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 28842-08 for ; Wed, 14 May 2008 23:40:53 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from yw-out-2324.google.com (yw-out-2324.google.com [74.125.46.30]) by developer.postgresql.org (Postfix) with ESMTP id 6E80E2E002D for ; Wed, 14 May 2008 23:40:59 -0300 (ADT) Received: by yw-out-2324.google.com with SMTP id 3so108781ywj.73 for ; Wed, 14 May 2008 19:40:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=X2QJPtEQOt+TdEZmaOgw6LgwXG35aJmzIO8mD7mt/U4=; b=JpoIjNWrK/n28xL5oCeJAhOxN33v1XTY6uq17pefh9eHqrc/gF6lv2XdGEA+pW3DU5IT8Jm5EfonKBsG0V+1OIshQkhjW5k+4NpcPR3sgjXrYgDSJ3s3r4lbDZBggDLuSsfUUnbRK6d2C6OQ0CaMVDQ1R4jbTcuqeN336SpPVPY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=LAaoQmZBMwQytDT2o6zHsAqQWJ9DXTSg4zMDCzLjYIEmEh7+Mv6k86zUUkLTcC1H8KlxANF6IROQBvIThH+fO87FC36fWH5tgq8wcsqrLT9RPz+kV4kq0N5jTuGrXx3nedgHLjkA0wYlJ3lsWk6tC+wx/B2Tyu4JRqyWibea+Vk= Received: by 10.151.83.12 with SMTP id k12mr1818502ybl.1.1210819258319; Wed, 14 May 2008 19:40:58 -0700 (PDT) Received: by 10.151.84.7 with HTTP; Wed, 14 May 2008 19:40:58 -0700 (PDT) Message-ID: <2e78013d0805141940x50c3f51u439019e8e592959@mail.gmail.com> Date: Thu, 15 May 2008 08:10:58 +0530 From: "Pavan Deolasee" To: "Greg Smith" Subject: Re: I/O on select count(*) Cc: "Alvaro Herrera" , pgsql-performance@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/193 X-Sequence-Number: 30161 On Thu, May 15, 2008 at 7:51 AM, Greg Smith wrote: > > > So is vacuum helpful here because it will force all that to happen in one > batch? To put that another way: if I've run a manual vacuum, is it true > that it will have updated all the hint bits to XMIN_COMMITTED for all the > tuples that were all done when the vacuum started? > Yes. For that matter, even a plain SELECT or count(*) on the entire table is good enough. That will check every tuple for visibility and set it's hint bits. Another point to note is that the hint bits are checked and set on a per tuple basis. So especially during index scan, the same heap page may get rewritten many times. I had suggested in the past that whenever we set hint bits for a tuple, we should check all other tuples in the page and set their hint bits too to avoid multiple writes of the same page. I guess the idea got rejected because of lack of benchmarks to prove the benefit. Thanks, Pavan -- Pavan Deolasee EnterpriseDB http://www.enterprisedb.com From llonergan@greenplum.com Thu May 15 02:53:08 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 1D7F22E0047 for ; Wed, 14 May 2008 23:53:08 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 37815-02 for ; Wed, 14 May 2008 23:52:48 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from exprod6og106.obsmtp.com (exprod6og106.obsmtp.com [64.18.1.191]) by developer.postgresql.org (Postfix) with SMTP id 2B9DF2E004F for ; Wed, 14 May 2008 23:52:54 -0300 (ADT) Received: from source ([63.240.6.3]) (using TLSv1) by exprod6ob106.postini.com ([64.18.5.12]) with SMTP; Wed, 14 May 2008 19:52:51 PDT Received: from d01smtp06.Mi8.com ([172.16.1.239]) by Outbound02.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 14 May 2008 22:55:32 -0400 Received: from MI8NYCMAIL08.Mi8.com ([172.16.1.164]) by d01smtp06.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 14 May 2008 22:55:32 -0400 Received: from 222.128.199.82 ([222.128.199.82]) by MI8NYCMAIL08.Mi8.com ([172.16.1.190]) via Exchange Front-End Server mi8owa.mi8.com ([172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Thu, 15 May 2008 02:54:49 +0000 User-Agent: Microsoft-Entourage/12.1.0.080305 Date: Thu, 15 May 2008 10:52:01 +0800 Subject: Re: I/O on select count(*) From: Luke Lonergan To: Pavan Deolasee , Greg Smith CC: Alvaro Herrera , Message-ID: Thread-Topic: [PERFORM] I/O on select count(*) Thread-Index: Aci2NY6smkjS3IfDSluaZeatjw9/XwAARdYc In-Reply-To: <2e78013d0805141940x50c3f51u439019e8e592959@mail.gmail.com> Mime-version: 1.0 Content-type: multipart/alternative; boundary="B_3293693521_4061378" X-OriginalArrivalTime: 15 May 2008 02:55:32.0678 (UTC) FILETIME=[24321E60:01C8B637] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.419 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001, MIME_QP_LONG_LINE=1.819, RCVD_IN_DNSWL_MED=-4, RCVD_NUMERIC_HELO=2.599 X-Spam-Level: X-Archive-Number: 200805/194 X-Sequence-Number: 30162 > This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --B_3293693521_4061378 Content-type: text/plain; charset="ISO-8859-1" Content-transfer-encoding: quoted-printable BTW =AD we=B9ve removed HINT bit checking in Greenplum DB and improved the visibility caching which was enough to provide performance at the same leve= l as with the HINT bit optimization, but avoids this whole =B3write the data, write it to the log also, then write it again just for good measure=B2 behavior. For people doing data warehousing work like the poster, this Postgres behavior is miserable. It should be fixed for 8.4 for sure (volunteers?) BTW =AD for the poster=B9s benefit, you should implement partitioning by date, then load each partition and VACUUM ANALYZE after each load. You probably won=B9t need the date index anymore =AD so your load times will vastly improve (no indexes), you=B9ll store less data (no indexes) and you=B9ll be able to do simpler data management with the partitions. You may also want to partition AND index if you do a lot of short range selective date predicates. Example would be: partition by day, index on date field, queries selective on date ranges by hour will then select out only the day needed, then index scan to get the hourly values. Typically time-oriented data is nearly time sorted anyway, so you=B9ll also get the benefit of a clustered index. - Luke On 5/15/08 10:40 AM, "Pavan Deolasee" wrote: > On Thu, May 15, 2008 at 7:51 AM, Greg Smith wrote: >> > >> > >> > So is vacuum helpful here because it will force all that to happen in = one >> > batch? To put that another way: if I've run a manual vacuum, is it t= rue >> > that it will have updated all the hint bits to XMIN_COMMITTED for all = the >> > tuples that were all done when the vacuum started? >> > >=20 > Yes. For that matter, even a plain SELECT or count(*) on the entire > table is good enough. That will check every tuple for visibility and > set it's hint bits. >=20 > Another point to note is that the hint bits are checked and set on a > per tuple basis. So especially during index scan, the same heap page > may get rewritten many times. I had suggested in the past that > whenever we set hint bits for a tuple, we should check all other > tuples in the page and set their hint bits too to avoid multiple > writes of the same page. I guess the idea got rejected because of lack > of benchmarks to prove the benefit. >=20 > Thanks, > Pavan >=20 > -- > Pavan Deolasee > EnterpriseDB http://www.enterprisedb.com >=20 > -- > Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org= ) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-performance >=20 --B_3293693521_4061378 Content-type: text/html; charset="ISO-8859-1" Content-transfer-encoding: quoted-printable Re: [PERFORM] I/O on select count(*) BTW – we’ve removed HINT bit checking in Greenplum DB an= d improved the visibility caching which was enough to provide performance at= the same level as with the HINT bit optimization, but avoids this whole = 220;write the data, write it to the log also, then write it again just for g= ood measure” behavior.

For people doing data warehousing work like the poster, this Postgres behav= ior is miserable.  It should be fixed for 8.4 for sure (volunteers?)
BTW – for the poster’s benefit, you should implement partitioni= ng by date, then load each partition and VACUUM ANALYZE after each load. &nb= sp;You probably won’t need the date index anymore – so your load= times will vastly improve (no indexes), you’ll store less data (no in= dexes) and you’ll be able to do simpler data management with the parti= tions.

You may also want to partition AND index if you do a lot of short range sel= ective date predicates.  Example would be: partition by day, index on d= ate field, queries selective on date ranges by hour will then select out onl= y the day needed, then index scan to get the hourly values.  Typically = time-oriented data is nearly time sorted anyway, so you’ll also get th= e benefit of a clustered index.

- Luke


On 5/15/08 10:40 AM, "Pavan Deolasee" <pavan.deolasee@gmail.co= m> wrote:

On Thu, May 15, 2008 at 7:51 AM, Gr= eg Smith <gsmith@gregsmith.com> wrote:
>
>
> So is vacuum helpful here because it will force all that to happen in = one
> batch?  To put that another way:  if I've run a manual vacuu= m, is it true
> that it will have updated all the hint bits to XMIN_COMMITTED for all = the
> tuples that were all done when the vacuum started?
>

Yes. For that matter, even a plain SELECT or count(*) on the entire
table is good enough. That will check every tuple for visibility and
set it's hint bits.

Another point to note is that the hint bits are checked and set on a
per tuple basis. So especially during index scan, the same heap page
may get rewritten many times. I had suggested in the past that
whenever we set hint bits for a tuple, we should check all other
tuples in the page and set their hint bits too to avoid multiple
writes of the same page. I guess the idea got rejected because of lack
of benchmarks to prove the benefit.

Thanks,
Pavan

--
Pavan Deolasee
EnterpriseDB http://www.enterprisedb.= com

--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)<= BR> To make changes to your subscription:
http://www.p= ostgresql.org/mailpref/pgsql-performance

--B_3293693521_4061378-- From gsmith@gregsmith.com Thu May 15 03:07:55 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 2233A2E0059 for ; Thu, 15 May 2008 00:07:55 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 47276-09 for ; Thu, 15 May 2008 00:07:43 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from westnet.com (westnet.com [216.187.52.2]) by developer.postgresql.org (Postfix) with ESMTP id 654CC2E0047 for ; Thu, 15 May 2008 00:03:40 -0300 (ADT) Received: from westnet.com (localhost [127.0.0.1]) by westnet.com (8.14.0/8.14.0) with ESMTP id m4F33c30012800; Wed, 14 May 2008 23:03:38 -0400 (EDT) Received: from localhost (gsmith@localhost) by westnet.com (8.14.0/8.13.2/Submit) with ESMTP id m4F33boZ012791; Wed, 14 May 2008 23:03:37 -0400 (EDT) X-Authentication-Warning: westnet.com: gsmith owned process doing -bs Date: Wed, 14 May 2008 23:03:37 -0400 (EDT) From: Greg Smith X-X-Sender: gsmith@westnet.com To: Pavan Deolasee cc: Alvaro Herrera , pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) In-Reply-To: <2e78013d0805141940x50c3f51u439019e8e592959@mail.gmail.com> Message-ID: References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <2e78013d0805141940x50c3f51u439019e8e592959@mail.gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/195 X-Sequence-Number: 30163 On Thu, 15 May 2008, Pavan Deolasee wrote: > I had suggested in the past that whenever we set hint bits for a tuple, > we should check all other tuples in the page and set their hint bits too > to avoid multiple writes of the same page. I guess the idea got rejected > because of lack of benchmarks to prove the benefit. From jd@commandprompt.com Thu May 15 03:14:15 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id D67242E0035 for ; Thu, 15 May 2008 00:14:15 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 50122-07-2 for ; Thu, 15 May 2008 00:13:40 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from lists.commandprompt.com (host-159.commandprompt.net [207.173.203.159]) by developer.postgresql.org (Postfix) with ESMTP id D4A7D2E003A for ; Thu, 15 May 2008 00:13:07 -0300 (ADT) Received: from jd-laptop (cmdalert.com [69.55.229.115]) (authenticated bits=0) by lists.commandprompt.com (8.13.8/8.13.8) with ESMTP id m4F3Dvrh009703 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 14 May 2008 20:13:58 -0700 Date: Wed, 14 May 2008 20:13:30 -0700 From: "Joshua D. Drake" To: Luke Lonergan Cc: Pavan Deolasee , Greg Smith , Alvaro Herrera , Subject: Re: I/O on select count(*) Message-ID: <20080514201330.5293c5bf@jd-laptop> In-Reply-To: References: <2e78013d0805141940x50c3f51u439019e8e592959@mail.gmail.com> Organization: Joshua D. Drake X-Mailer: Claws Mail 3.4.0 (GTK+ 2.12.9; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/irQgdRw5X/R7kOiMSvc5fAt"; protocol="application/pgp-signature"; micalg=PGP-SHA1 X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0 (lists.commandprompt.com [207.173.203.159]); Wed, 14 May 2008 20:13:58 -0700 (PDT) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/196 X-Sequence-Number: 30164 --Sig_/irQgdRw5X/R7kOiMSvc5fAt Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Thu, 15 May 2008 10:52:01 +0800 Luke Lonergan wrote: > BTW =C2=AD we=C2=B9ve removed HINT bit checking in Greenplum DB and impro= ved the > visibility caching which was enough to provide performance at the > same level as with the HINT bit optimization, but avoids this whole > =C2=B3write the data, write it to the log also, then write it again just > for good measure=C2=B2 behavior. >=20 > For people doing data warehousing work like the poster, this Postgres > behavior is miserable. It should be fixed for 8.4 for sure > (volunteers?) Donations? You have the code Luke :) Sincerely, Joshua D. Drake P.S. Sorry for the almost bad Star Wars pun. --=20 The PostgreSQL Company since 1997: http://www.commandprompt.com/=20 PostgreSQL Community Conference: http://www.postgresqlconference.org/ United States PostgreSQL Association: http://www.postgresql.us/ Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate --Sig_/irQgdRw5X/R7kOiMSvc5fAt Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFIK6pdATb/zqfZUUQRAiuzAJ9qNxaGHjGIjd1Vdc6eMvGi/5E8IgCgjFxG Sxv3wuC4NZJC5e5k7jbHZ3I= =zUEW -----END PGP SIGNATURE----- --Sig_/irQgdRw5X/R7kOiMSvc5fAt-- From tino@wildenhain.de Thu May 15 06:14:25 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 5BAA22E0127 for ; Thu, 15 May 2008 03:14:25 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 65379-07 for ; Thu, 15 May 2008 03:13:45 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from service-web.de (p15093784.pureserver.info [217.160.106.224]) by developer.postgresql.org (Postfix) with ESMTP id 1A0302E00B7 for ; Thu, 15 May 2008 02:20:27 -0300 (ADT) Received: from [145.228.94.72] (unknown [145.228.94.72]) by service-web.de (Postfix) with ESMTP id 33DD3E8138; Thu, 15 May 2008 07:20:21 +0200 (CEST) Message-ID: <482BC80B.3010109@wildenhain.de> Date: Thu, 15 May 2008 07:20:11 +0200 From: Tino Wildenhain User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 To: Luke Lonergan Cc: Pavan Deolasee , Greg Smith , Alvaro Herrera , pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) References: In-Reply-To: Content-Type: multipart/signed; protocol="application/x-pkcs7-signature"; micalg=sha1; boundary="------------ms010109000703010000020904" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/197 X-Sequence-Number: 30165 This is a cryptographically signed message in MIME format. --------------ms010109000703010000020904 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: quoted-printable Hi, Luke Lonergan wrote: > BTW =96 we=92ve removed HINT bit checking in Greenplum DB and improved = the=20 > visibility caching which was enough to provide performance at the same = > level as with the HINT bit optimization, but avoids this whole =93write= =20 > the data, write it to the log also, then write it again just for good=20 > measure=94 behavior. can you go a bit deeper into how you implemented this or is it some IP of greenplum you cannot reveal? Btw, is there something with your eyes: ? :-)) Cheers Tino --------------ms010109000703010000020904 Content-Type: application/x-pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" Content-Description: S/MIME Cryptographic Signature MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIJBzCC At4wggJHoAMCAQICEFhzOX0yh1CxCcTpCoXqqXkwDQYJKoZIhvcNAQEFBQAwYjELMAkGA1UE BhMCWkExJTAjBgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAqBgNVBAMT I1RoYXd0ZSBQZXJzb25hbCBGcmVlbWFpbCBJc3N1aW5nIENBMB4XDTA4MDQzMDE5MzY1NFoX DTA5MDQzMDE5MzY1NFowRDEfMB0GA1UEAxMWVGhhd3RlIEZyZWVtYWlsIE1lbWJlcjEhMB8G CSqGSIb3DQEJARYSdGlub0B3aWxkZW5oYWluLmRlMIIBIjANBgkqhkiG9w0BAQE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wdjBiMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkg THRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECEFhz OX0yh1CxCcTpCoXqqXkwgYcGCyqGSIb3DQEJEAILMXigdjBiMQswCQYDVQQGEwJaQTElMCMG A1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBl cnNvbmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECEFhzOX0yh1CxCcTpCoXqqXkwDQYJKoZIhvcN AQEBBQAEggEAQLAFCSXzzN6jIF7m/voZYat2K5O2eXXWmICZyM+p6yi4SaOSwbwdUsT3EYJ5 n13xvFuW07Wd7Te+GcVejw7FrQ6uyxJTEqPRhwp5PfCgh1G0dBYCtRqAyyVLI1GJllBSYRWf tZCSAxUEyC8oEirEwjcO2NMvydIqla3M0hYImLNkmiEv5q6JOiJhdICyFbGwwhIXstJoAjn0 ipDfWWTm9wGtA8HTGl++glJuuDS+fixZeGvF62vCz6DIUvJtKi+w4rI3QKKlQPsMN7OJ4Ihn 61XZLIbceevZR5Nu2kVd/M+F1IMy+NCd9S1d88nFPyWndx+qQRUAWJdmAqOATS3mPwAAAAAA AA== --------------ms010109000703010000020904-- From tgl@sss.pgh.pa.us Thu May 15 07:54:52 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 7675E2E0102 for ; Thu, 15 May 2008 04:54:52 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 98832-02-3 for ; Thu, 15 May 2008 04:54:27 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by developer.postgresql.org (Postfix) with ESMTP id 6878F2E00C7 for ; Thu, 15 May 2008 04:02:22 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m4F72Jok028325; Thu, 15 May 2008 03:02:19 -0400 (EDT) To: "Jan de Visser" cc: "Greg Smith" , "Alvaro Herrera" , pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) In-reply-to: <1159c1e90805141938j5f85b490rb5c1cfdf9e428bce@mail.gmail.com> References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <1159c1e90805141938j5f85b490rb5c1cfdf9e428bce@mail.gmail.com> Comments: In-reply-to "Jan de Visser" message dated "Wed, 14 May 2008 22:38:08 -0400" Date: Thu, 15 May 2008 03:02:19 -0400 Message-ID: <28324.1210834939@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/198 X-Sequence-Number: 30166 "Jan de Visser" writes: > Obviously, this issue is tied to the slow count(*) one, as I found out > the hard way. Consider the following scenario: > * Insert row > * Update that row a couple of times > * Rinse and repeat many times > Now somewhere during that cycle, do a select count(*) just to see > where you are. You will be appalled by how slow that is, due to not > only the usual 'slow count(*)' reasons. This whole hint bit business > makes it even worse, as demonstrated by the fact that running a vacuum > before the count(*) makes the latter noticably faster. Uh, well, you can't blame that entirely on hint-bit updates. The vacuum has simply *removed* two-thirds of the rows in the system, resulting in a large drop in the number of rows that the select even has to look at. It's certainly true that hint-bit updates cost something, but quantifying how much isn't easy. The off-the-cuff answer is to do the select count(*) twice and see how much cheaper the second one is. But there are two big holes in that answer: the first is the possible cache effects from having already read in the pages, and the second is that the follow-up scan gets to avoid the visits to pg_clog that the first scan had to make (which after all is the point of the hint bits). I don't know any easy way to disambiguate the three effects that are at work here. But blaming it all on the costs of writing out hint-bit updates is wrong. regards, tom lane From tgl@sss.pgh.pa.us Thu May 15 08:00:17 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 67B242E0120 for ; Thu, 15 May 2008 05:00:17 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 10509-01-4 for ; Thu, 15 May 2008 04:59:47 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by developer.postgresql.org (Postfix) with ESMTP id 33B2C2E01AA for ; Thu, 15 May 2008 04:07:11 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m4F7798H028389; Thu, 15 May 2008 03:07:09 -0400 (EDT) To: Greg Smith cc: Alvaro Herrera , pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) In-reply-to: References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> Comments: In-reply-to Greg Smith message dated "Wed, 14 May 2008 22:21:45 -0400" Date: Thu, 15 May 2008 03:07:09 -0400 Message-ID: <28388.1210835229@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/199 X-Sequence-Number: 30167 Greg Smith writes: > ... To put that another way: if I've run a manual vacuum, is it true > that it will have updated all the hint bits to XMIN_COMMITTED for all the > tuples that were all done when the vacuum started? Any examination whatsoever of a tuple --- whether by vacuum or any ordinary DML operation --- will update its hint bits to match the commit/abort status of the inserting/deleting transaction(s) as of the instant of the examination. Your statement above is true but is weaker than reality. regards, tom lane From matthew@flymine.org Thu May 15 12:40:05 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 084842E00C7 for ; Thu, 15 May 2008 09:40:05 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 48241-01 for ; Thu, 15 May 2008 09:39:44 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from ppsw-9.csi.cam.ac.uk (ppsw-9.csi.cam.ac.uk [131.111.8.139]) by developer.postgresql.org (Postfix) with ESMTP id 578C42E004F for ; Thu, 15 May 2008 09:37:48 -0300 (ADT) X-Cam-SpamDetails: Not scanned X-Cam-AntiVirus: No virus found X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from flymine.sysbiol.cam.ac.uk ([131.111.60.120]:54679 helo=flymine.flymine.org) by ppsw-9.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.139]:25) with esmtp id 1JwciE-0003Ek-Vb (Exim 4.67) for pgsql-performance@postgresql.org (return-path ); Thu, 15 May 2008 13:37:34 +0100 Received: from host103 ([192.168.128.103] helo=aragorn.flymine.org ident=Debian-exim) by flymine.flymine.org with esmtp (Exim 4.12) id 1JwciE-00046R-00 for pgsql-performance@postgresql.org; Thu, 15 May 2008 13:37:34 +0100 Received: from mnw21 (helo=localhost) by aragorn.flymine.org with local-esmtp (Exim 4.69) (envelope-from ) id 1JwciE-0002Qq-N9 for pgsql-performance@postgresql.org; Thu, 15 May 2008 13:37:34 +0100 Date: Thu, 15 May 2008 13:37:34 +0100 (BST) From: Matthew Wakeling X-X-Sender: mnw21@aragorn.flymine.org To: pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) In-Reply-To: <20080515020553.GN9838@alvh.no-ip.org> Message-ID: References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/204 X-Sequence-Number: 30172 On Wed, 14 May 2008, Alvaro Herrera wrote: > Hint bits are used to mark tuples as created and/or deleted by > transactions that are know committed or aborted. To determine the > visibility of a tuple without such bits set, you need to consult pg_clog > and possibly pg_subtrans, so it is an expensive check. So, as I understand it, Postgres works like this: 1. You begin a transaction. Postgres writes an entry into pg_clog. 2. You write some tuples. Postgres writes them to the WAL, but doesn't bother fsyncing. 3. At some point, the bgwriter or a checkpoint may write the tuples to the database tables, and fsync the lot. 4. You commit the transaction. Postgres alters pg_clog again, writes that to the WAL, and fsyncs the WAL. 5. If the tuples hadn't already made it to the database tables, then a checkpoint or bgwriter will do it later on, and fsync the lot. 6. You read the tuples. Postgres reads them from the database table, looks in pg_clog, notices that the transaction has been committed, and writes the tuples to the database table again with the hint bits set. This write is not WAL protected, and is not fsynced. This seems like a good architecture, with some cool characteristics, mainly that at no point does Postgres have to hold vast quantities of data in memory. I have two questions though: Is it really safe to update the hint bits in place? If there is a power cut in the middle of writing a block, is there a guarantee from the disc that the block will never be garbled? Is there a way to make a shortcut and have the hint bits written the first time the data is written to the table? One piece of obvious low-hanging fruit would be to enhance step five above, so that the bgwriter or checkpoint that writes the data to the database table checks the pg_clog and writes the correct hint bits. In fact, if the tuple's creating transaction has aborted, then the tuple can be vacuumed right there and then before it is even written. For OLTP, almost all the hint bits will be written first time, and also the set of transactions that will be looked up in the pg_clog will be small (the set of transactions that were active since the last checkpoint), so its cache coherency will be good. However, this idea does not deal well with bulk data loads, where the data is checkpointed before transaction is committed or aborted. Matthew -- Now, you would have thought these coefficients would be integers, given that we're working out integer results. Using a fraction would seem really stupid. Well, I'm quite willing to be stupid here - in fact, I'm going to use complex numbers. -- Computer Science Lecturer From heikki@enterprisedb.com Thu May 15 12:54:24 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 3A52D2E006F for ; Thu, 15 May 2008 09:54:24 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 78153-03-5 for ; Thu, 15 May 2008 09:54:10 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail01.enterprisedb.com (mail01.enterprisedb.com [63.246.7.168]) by developer.postgresql.org (Postfix) with ESMTP id B24F02E0087 for ; Thu, 15 May 2008 09:52:36 -0300 (ADT) thread-index: Aci2iqXO1WdKv2zWS0+D15kJKSyQjA== Content-Class: urn:content-classes:message Importance: normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4133 Received: from [192.168.1.33] ([82.2.54.3]) by mail01.enterprisedb.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Thu, 15 May 2008 08:53:17 -0400 Message-ID: <482C320F.9070908@enterprisedb.com> Date: Thu, 15 May 2008 13:52:31 +0100 From: "Heikki Linnakangas" Organization: EnterpriseDB User-Agent: Mozilla-Thunderbird 2.0.0.12 (X11/20080420) MIME-Version: 1.0 To: "Matthew Wakeling" Cc: Subject: Re: I/O on select count(*) References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> In-Reply-To: Content-Type: text/plain; format=flowed; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 15 May 2008 12:53:18.0062 (UTC) FILETIME=[A5A168E0:01C8B68A] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/205 X-Sequence-Number: 30173 Matthew Wakeling wrote: > Is it really safe to update the hint bits in place? If there is a power > cut in the middle of writing a block, is there a guarantee from the disc > that the block will never be garbled? Don't know, to be honest. We've never seen any reports of corrupted data that would suggest such a problem, but it doesn't seem impossible to me that some exotic storage system might do that. > Is there a way to make a shortcut and have the hint bits written the > first time the data is written to the table? One piece of obvious > low-hanging fruit would be to enhance step five above, so that the > bgwriter or checkpoint that writes the data to the database table checks > the pg_clog and writes the correct hint bits. Yep, that's an idea that's been suggested before. In fact, I seem to remember a patch to do just that. Don't remember what happened to it, > In fact, if the tuple's > creating transaction has aborted, then the tuple can be vacuumed right > there and then before it is even written. Not if you have any indexes on the table. To vacuum, you'll have to scan all indexes to remove pointers to the tuple. > However, this idea does not deal well with bulk data loads, where the > data is checkpointed before transaction is committed or aborted. Yep, that's the killer :-(. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com From matthew@flymine.org Thu May 15 12:55:11 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 59DCE2E0031 for ; Thu, 15 May 2008 09:55:11 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 78153-03-8 for ; Thu, 15 May 2008 09:54:52 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from ppsw-6.csi.cam.ac.uk (ppsw-6.csi.cam.ac.uk [131.111.8.136]) by developer.postgresql.org (Postfix) with ESMTP id 62EA42E0068 for ; Thu, 15 May 2008 09:54:22 -0300 (ADT) X-Cam-SpamDetails: Not scanned X-Cam-AntiVirus: No virus found X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from flymine.sysbiol.cam.ac.uk ([131.111.60.120]:54698 helo=flymine.flymine.org) by ppsw-6.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.136]:25) with esmtp id 1JwcyL-0008RG-Jz (Exim 4.67) for pgsql-performance@postgresql.org (return-path ); Thu, 15 May 2008 13:54:13 +0100 Received: from host103 ([192.168.128.103] helo=aragorn.flymine.org ident=Debian-exim) by flymine.flymine.org with esmtp (Exim 4.12) id 1JwcyL-00049I-00 for pgsql-performance@postgresql.org; Thu, 15 May 2008 13:54:13 +0100 Received: from mnw21 (helo=localhost) by aragorn.flymine.org with local-esmtp (Exim 4.69) (envelope-from ) id 1JwcyL-0002ZH-3d for pgsql-performance@postgresql.org; Thu, 15 May 2008 13:54:13 +0100 Date: Thu, 15 May 2008 13:54:13 +0100 (BST) From: Matthew Wakeling X-X-Sender: mnw21@aragorn.flymine.org To: pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Virus-Scanned: Maia Mailguard 1.0.1 Content-Type: TEXT/PLAIN; CHARSET=iso-8859-1; FORMAT=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Content-ID: X-Archive-Number: 200805/206 X-Sequence-Number: 30174 On Thu, 15 May 2008, Luke Lonergan wrote: > BTW =AD we=B9ve removed HINT bit checking in Greenplum DB and improved the > visibility caching which was enough to provide performance at the same le= vel > as with the HINT bit optimization, but avoids this whole =B3write the dat= a, > write it to the log also, then write it again just for good measure=B2 > behavior. This sounds like a good option. I believe I suggested this a few months=20 ago, however it was rejected because in the worst case (when the hints are= =20 not cached), if you're doing an index scan, you can do twice the number of= =20 seeks as before. http://archives.postgresql.org/pgsql-performance/2007-12/msg00217.php The hint data will be four bits per tuple plus overheads, so it could be=20 made very compact, and therefore likely to stay in the cache fairly well.= =20 Each tuple fetched would have to be spaced really far apart in the=20 database table in order to exhibit the worst case, because fetching a page= =20 of hint cache will cause 64kB or so of disc to appear in the disc's=20 read-ahead buffer, which will be equivalent to 128MB worth of database=20 table (assuming eight tuples per block and no overhead). As soon as you=20 access another tuple in the same 128MB bracket, you'll hit the disc=20 read-ahead buffer for the hints. On balance, to me it still seems like a good option. Matthew --=20 Those who do not understand Unix are condemned to reinvent it, poorly. -- Henry Spencer= From jdevisser@digitalfairway.com Thu May 15 13:15:50 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 31A8F2E0056 for ; Thu, 15 May 2008 10:15:50 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 24124-08 for ; Thu, 15 May 2008 10:15:32 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.177]) by developer.postgresql.org (Postfix) with ESMTP id F01002E0052 for ; Thu, 15 May 2008 10:15:34 -0300 (ADT) Received: by py-out-1112.google.com with SMTP id d37so402520pye.29 for ; Thu, 15 May 2008 06:15:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:date:user-agent:cc:references:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:message-id:sender; bh=Dd+V0FxEo4IdH3+tdYd1TRiXEheMKqwwR8tKiiNd0gA=; b=Uf1cG9XHfM4f2t2GChk7wpB9xV1fBoo2Ve4QITyU674vqkOqy6Wr3vNcOCrbiAzy5Rin/5wqAJLCasBCpr/gRmO3QXSHLGPvkR6moh6CJD+W6ajIqn6S9ewSF6rHF74VGyORveIbW1cFzhm8yTLVsc5qoBe0UiU8tLvTIObDDu0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:cc:references:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:message-id:sender; b=sdj02HJNJfJHxTowxwCJqCmn92AbgaWk77bFwqSX5TuhQQvWZXTxhtjbWT0xKWGr1u8gQ1FiSotsh41UeMV792y9Zen9NQTQ/UulZvlYBLq2SLC1LXjOWIl/GixNVS6CWK//sBfZ+P4mpkm2RX89SfsoP5TwOhl9ttS6fTrdH78= Received: by 10.65.44.11 with SMTP id w11mr3411689qbj.11.1210857333222; Thu, 15 May 2008 06:15:33 -0700 (PDT) Received: from kitchener.toronto.digitalfairway.ca ( [24.235.117.179]) by mx.google.com with ESMTPS id q13sm3321167qbq.15.2008.05.15.06.15.32 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 15 May 2008 06:15:32 -0700 (PDT) From: Jan de Visser To: Tom Lane Subject: Re: I/O on select count(*) Date: Thu, 15 May 2008 09:15:40 -0400 User-Agent: KMail/1.9.9 Cc: "Greg Smith" , "Alvaro Herrera" , pgsql-performance@postgresql.org References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <1159c1e90805141938j5f85b490rb5c1cfdf9e428bce@mail.gmail.com> <28324.1210834939@sss.pgh.pa.us> In-Reply-To: <28324.1210834939@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200805150915.40793.jdevisser@digitalfairway.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/207 X-Sequence-Number: 30175 On Thursday 15 May 2008 03:02:19 Tom Lane wrote: > "Jan de Visser" writes: > > Obviously, this issue is tied to the slow count(*) one, as I found out > > the hard way. Consider the following scenario: > > * Insert row > > * Update that row a couple of times > > * Rinse and repeat many times > > > > Now somewhere during that cycle, do a select count(*) just to see > > where you are. You will be appalled by how slow that is, due to not > > only the usual 'slow count(*)' reasons. This whole hint bit business > > makes it even worse, as demonstrated by the fact that running a vacuum > > before the count(*) makes the latter noticably faster. > > Uh, well, you can't blame that entirely on hint-bit updates. The vacuum > has simply *removed* two-thirds of the rows in the system, resulting in > a large drop in the number of rows that the select even has to look at. > > It's certainly true that hint-bit updates cost something, but > quantifying how much isn't easy. The off-the-cuff answer is to do the > select count(*) twice and see how much cheaper the second one is. But > there are two big holes in that answer: the first is the possible cache > effects from having already read in the pages, and the second is that > the follow-up scan gets to avoid the visits to pg_clog that the first > scan had to make (which after all is the point of the hint bits). > > I don't know any easy way to disambiguate the three effects that are at > work here. But blaming it all on the costs of writing out hint-bit > updates is wrong. > > regards, tom lane True. But it still contributes to the fact that queries sometimes behave in a non-deterministic way, which IMHO is the major annoyance when starting to work with pgsql. And contrary to other causes (vacuum, checkpoints) this is woefully underdocumented. jan From matthew@flymine.org Thu May 15 13:39:31 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 3001F2E0097 for ; Thu, 15 May 2008 10:39:31 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 77738-01-3 for ; Thu, 15 May 2008 10:39:14 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from ppsw-7.csi.cam.ac.uk (ppsw-7.csi.cam.ac.uk [131.111.8.137]) by developer.postgresql.org (Postfix) with ESMTP id DDA4C2E009A for ; Thu, 15 May 2008 10:38:57 -0300 (ADT) X-Cam-SpamDetails: Not scanned X-Cam-AntiVirus: No virus found X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from flymine.sysbiol.cam.ac.uk ([131.111.60.120]:54747 helo=flymine.flymine.org) by ppsw-7.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.137]:25) with esmtp id 1JwdfU-0005H7-OS (Exim 4.67) for pgsql-performance@postgresql.org (return-path ); Thu, 15 May 2008 14:38:48 +0100 Received: from host103 ([192.168.128.103] helo=aragorn.flymine.org ident=Debian-exim) by flymine.flymine.org with esmtp (Exim 4.12) id 1JwdfU-0004Gi-00 for pgsql-performance@postgresql.org; Thu, 15 May 2008 14:38:48 +0100 Received: from mnw21 (helo=localhost) by aragorn.flymine.org with local-esmtp (Exim 4.69) (envelope-from ) id 1JwdfU-0002vb-FQ for pgsql-performance@postgresql.org; Thu, 15 May 2008 14:38:48 +0100 Date: Thu, 15 May 2008 14:38:48 +0100 (BST) From: Matthew Wakeling X-X-Sender: mnw21@aragorn.flymine.org To: pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) In-Reply-To: <482C320F.9070908@enterprisedb.com> Message-ID: References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <482C320F.9070908@enterprisedb.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/208 X-Sequence-Number: 30176 On Thu, 15 May 2008, Heikki Linnakangas wrote: > > Is it really safe to update the hint bits in place? If there is a > > power cut in the middle of writing a block, is there a guarantee from > > the disc that the block will never be garbled? > > Don't know, to be honest. We've never seen any reports of corrupted data > that would suggest such a problem, but it doesn't seem impossible to me > that some exotic storage system might do that. Hmm. That problem is what WAL full-page-writes is meant to handle, isn't it? So basically, if you're telling people that WAL full-page-writes is safer than partial WAL, because it avoids updating pages in-place, then you shouldn't be updating pages in-place for the hint bits either. You can't win! >> In fact, if the tuple's creating transaction has aborted, then the tuple >> can be vacuumed right there and then before it is even written. > > Not if you have any indexes on the table. To vacuum, you'll have to scan all > indexes to remove pointers to the tuple. Ah. Well, would that be so expensive? After all, someone has to do it eventually, and these are index entries that have only just been added anyway. I can understand index updating being a bit messy in the middle of a checkpoint though, as you would have to write the update to the WAL, which you are checkpointing... So, I don't know exactly how the WAL updates to indexes work, but my guess is that it has been implemented as "write the blocks that we would change to the WAL". The problem with this is that all the changes to the index are done individually, so there's no easy way to "undo" one of them later on when you find out that the transaction has been aborted during the checkpoint. An alternative would be to build a "list of changes" in the WAL without actually changing the underlying index at all. When reading the index, you would read the "list" first (which would be in memory, and in an efficient-to-search structure), then read the original index and add the two. Then when checkpointing, vet all the changes against known aborted transactions before making all the changes to the index together. This is likely to speed up index writes quite a bit, and also allow you to effectively vacuum aborted tuples before they get written to the disc. Matthew -- Vacuums are nothings. We only mention them to let them know we know they're there. From rm_pg@cheapcomplexdevices.com Thu May 15 13:51:16 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 633962E0052 for ; Thu, 15 May 2008 10:51:16 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 00630-03 for ; Thu, 15 May 2008 10:50:38 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp110.biz.mail.mud.yahoo.com (smtp110.biz.mail.mud.yahoo.com [68.142.201.179]) by developer.postgresql.org (Postfix) with SMTP id 750B62E0056 for ; Thu, 15 May 2008 10:50:40 -0300 (ADT) Received: (qmail 28648 invoked from network); 15 May 2008 13:50:39 -0000 Received: from unknown (HELO ?192.168.5.105?) (ramayer@forensiclogic.com@76.199.136.9 with plain) by smtp110.biz.mail.mud.yahoo.com with SMTP; 15 May 2008 13:50:38 -0000 X-YMail-OSG: oIR.mQwVM1kQLsuAklcoHgUi4mYj4X636S.83qSVoSjGOJYPFe_DTXzGhCXQjYrqJyG73JwAG5lfhenk5lxxam.6CV3Gt1C7tcnF9SALhTXIyKGTVU5t20.qhMu7V6F5xMA- X-Yahoo-Newman-Property: ymail-3 Message-ID: <482C3FB4.6050102@cheapcomplexdevices.com> Date: Thu, 15 May 2008 06:50:44 -0700 From: Ron Mayer User-Agent: Mozilla-Thunderbird 2.0.0.12 (X11/20080420) MIME-Version: 1.0 To: Matthew Wakeling CC: pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/209 X-Sequence-Number: 30177 Matthew Wakeling wrote: > On Thu, 15 May 2008, Luke Lonergan wrote: >> ...HINT bit optimization, but avoids this whole ³write the data, >> write it to the log also, then write it again just for good measure² > ... > The hint data will be four bits per tuple plus overheads, so it could be > made very compact, and therefore likely to stay in the cache fairly > well. Does it seem like these HINT bits would be good candidates to move off to map forks similar to how the visibility map stuff will be handled? Since (if I understand right) only the hint bits change during the select(*) it seems a lot less write-IO would happen if such a map were updated rather than the data pages themselves. From alvherre@commandprompt.com Thu May 15 14:41:48 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id DCEF92E0068 for ; Thu, 15 May 2008 11:41:48 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 04880-02 for ; Thu, 15 May 2008 11:41:27 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from lists.commandprompt.com (host-159.commandprompt.net [207.173.203.159]) by developer.postgresql.org (Postfix) with ESMTP id A72382E006C for ; Thu, 15 May 2008 11:41:22 -0300 (ADT) Received: from perhan.alvh.no-ip.org (200-126-123-196.bk8-dsl.surnet.cl [200.126.123.196]) (authenticated bits=0) by lists.commandprompt.com (8.13.8/8.13.8) with ESMTP id m4FEgCdK005026 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 15 May 2008 07:42:15 -0700 Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id A5D2047C5E; Thu, 15 May 2008 10:41:06 -0400 (CLT) Date: Thu, 15 May 2008 10:41:06 -0400 From: Alvaro Herrera To: Greg Smith Cc: Pavan Deolasee , pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) Message-ID: <20080515144106.GA8221@alvh.no-ip.org> References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <2e78013d0805141940x50c3f51u439019e8e592959@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0 (lists.commandprompt.com [207.173.203.159]); Thu, 15 May 2008 07:42:15 -0700 (PDT) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/211 X-Sequence-Number: 30179 Greg Smith escribió: > On Thu, 15 May 2008, Pavan Deolasee wrote: > >> I had suggested in the past that whenever we set hint bits for a tuple, >> we should check all other tuples in the page and set their hint bits >> too to avoid multiple writes of the same page. I guess the idea got >> rejected because of lack of benchmarks to prove the benefit. > > From glancing at http://www.postgresql.org/docs/faqs.TODO.html I got the > impression the idea was to have the background writer get involved to > help with this particular situation. The problem is that the bgwriter does not understand about the content of the pages it is writing -- they're opaque pages for all it knows. So it cannot touch the hint bits. I agree with Pavan that it's likely that setting hint bits in batches instead of just for the tuple being examined is a benefit. However, it's perhaps not so good to be doing it in a foreground process, because you're imposing extra cost to the client queries which we want to be as fast as possible. Perhaps the thing to do is have a "database-local bgwriter" which would scan pages and do this kind of change ... a different kind of process to be launched by autovacuum perhaps. If we had the bitmask in a separate map fork, this could be cheap. -- Alvaro Herrera http://www.CommandPrompt.com/ The PostgreSQL Company - Command Prompt, Inc. From tgl@sss.pgh.pa.us Thu May 15 14:57:57 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 119442E0068 for ; Thu, 15 May 2008 11:57:57 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 38435-05 for ; Thu, 15 May 2008 11:57:44 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by developer.postgresql.org (Postfix) with ESMTP id C9ED32E008D for ; Thu, 15 May 2008 11:53:01 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m4FEqwYY004759; Thu, 15 May 2008 10:52:58 -0400 (EDT) To: Matthew Wakeling cc: pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) In-reply-to: References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <482C320F.9070908@enterprisedb.com> Comments: In-reply-to Matthew Wakeling message dated "Thu, 15 May 2008 14:38:48 +0100" Date: Thu, 15 May 2008 10:52:58 -0400 Message-ID: <4758.1210863178@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/212 X-Sequence-Number: 30180 Matthew Wakeling writes: > Hmm. That problem is what WAL full-page-writes is meant to handle, isn't > it? So basically, if you're telling people that WAL full-page-writes is > safer than partial WAL, because it avoids updating pages in-place, then > you shouldn't be updating pages in-place for the hint bits either. You > can't win! This argument ignores the nature of the data change. With a hint-bit update, no data is being shuffled around, so there is no danger from a partial page write. A disk that leaves an individual sector corrupt would be a problem, but I don't think that's a huge risk. Keep in mind that disks aren't designed to just stop dead when power dies --- they are made to be able to park their heads before the juice is entirely gone. I think it's reasonable to assume they'll finish writing the sector in progress before they start parking. regards, tom lane From heikki@enterprisedb.com Thu May 15 15:08:59 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id B49882E0078 for ; Thu, 15 May 2008 12:08:59 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 57420-07 for ; Thu, 15 May 2008 12:08:42 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail01.enterprisedb.com (mail01.enterprisedb.com [63.246.7.168]) by developer.postgresql.org (Postfix) with ESMTP id 63C032E0068 for ; Thu, 15 May 2008 12:08:42 -0300 (ADT) thread-index: Aci2naiC2iIwyU/0RIG0Om97U/g3TA== Content-Class: urn:content-classes:message Importance: normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4133 Received: from [192.168.1.33] ([82.2.54.3]) by mail01.enterprisedb.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Thu, 15 May 2008 11:09:22 -0400 Message-ID: <482C51F4.9070809@enterprisedb.com> Date: Thu, 15 May 2008 16:08:36 +0100 From: "Heikki Linnakangas" Organization: EnterpriseDB User-Agent: Mozilla-Thunderbird 2.0.0.12 (X11/20080420) MIME-Version: 1.0 To: "Matthew Wakeling" Cc: Subject: Re: I/O on select count(*) References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <482C320F.9070908@enterprisedb.com> In-Reply-To: Content-Type: text/plain; format=flowed; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 15 May 2008 15:09:23.0125 (UTC) FILETIME=[A8632650:01C8B69D] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/215 X-Sequence-Number: 30183 Matthew Wakeling wrote: > On Thu, 15 May 2008, Heikki Linnakangas wrote: >> > Is it really safe to update the hint bits in place? If there is a > >> power cut in the middle of writing a block, is there a guarantee from >> > the disc that the block will never be garbled? >> >> Don't know, to be honest. We've never seen any reports of corrupted >> data that would suggest such a problem, but it doesn't seem impossible >> to me that some exotic storage system might do that. > > Hmm. That problem is what WAL full-page-writes is meant to handle, isn't > it? So basically, if you're telling people that WAL full-page-writes is > safer than partial WAL, because it avoids updating pages in-place, then > you shouldn't be updating pages in-place for the hint bits either. You > can't win! Full-page-writes protect from torn pages, that is, when one half of an update hits the disk but the other one doesn't. In particular, if the beginning of the page where the WAL pointer (XLogRecPtr) is flushed to disk, but the actual changes elsewhere in the page aren't, you're in trouble. WAL replay will look at the WAL pointer, and think that the page doesn't need to be replayed, while other half of the update is still missing. Hint bits are different. We're only updating a single bit, and it doesn't matter from correctness point of view whether the hint bit update hits the disk or not. But what would spell trouble is if the disk controller/whatever garbles the whole sector, IOW changes something else than the changed bit, while doing the update. >>> In fact, if the tuple's creating transaction has aborted, then the >>> tuple can be vacuumed right there and then before it is even written. >> >> Not if you have any indexes on the table. To vacuum, you'll have to >> scan all indexes to remove pointers to the tuple. > > Ah. Well, would that be so expensive? After all, someone has to do it > eventually, and these are index entries that have only just been added > anyway. Scanning all indexes? Depends on your table of course, but yes it would be expensive in general. > An alternative would be to build a "list of changes" in the WAL without > actually changing the underlying index at all. When reading the index, > you would read the "list" first (which would be in memory, and in an > efficient-to-search structure), then read the original index and add the > two. Then when checkpointing, vet all the changes against known aborted > transactions before making all the changes to the index together. This > is likely to speed up index writes quite a bit, and also allow you to > effectively vacuum aborted tuples before they get written to the disc. There's not much point optimizing something that only helps with aborted transactions. The general problem with any idea that involves keeping a list of changes made in a transaction is that that list will grow big during bulk loads, so you'll have to overflow to disk or abandon the list approach. Which means that it won't help with bulk loads. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com From heikki@enterprisedb.com Thu May 15 15:16:11 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 388C32E0084 for ; Thu, 15 May 2008 12:16:11 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 73232-05 for ; Thu, 15 May 2008 12:15:57 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail01.enterprisedb.com (webmail.enterprisedb.com [63.246.7.168]) by developer.postgresql.org (Postfix) with ESMTP id BF6A22E0079 for ; Thu, 15 May 2008 12:15:57 -0300 (ADT) thread-index: Aci2nqxYmBff9lPhR1K0580n08h18A== Content-Class: urn:content-classes:message Importance: normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4133 Received: from [192.168.1.33] ([82.2.54.3]) by mail01.enterprisedb.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Thu, 15 May 2008 11:16:36 -0400 Message-ID: <482C53A6.2030802@enterprisedb.com> Date: Thu, 15 May 2008 16:15:50 +0100 From: "Heikki Linnakangas" Organization: EnterpriseDB User-Agent: Mozilla-Thunderbird 2.0.0.12 (X11/20080420) MIME-Version: 1.0 To: "Alvaro Herrera" Cc: "Greg Smith" , "Pavan Deolasee" , Subject: Re: I/O on select count(*) References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <2e78013d0805141940x50c3f51u439019e8e592959@mail.gmail.com> <20080515144106.GA8221@alvh.no-ip.org> In-Reply-To: <20080515144106.GA8221@alvh.no-ip.org> Content-Type: text/plain; format=flowed; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-OriginalArrivalTime: 15 May 2008 15:16:36.0437 (UTC) FILETIME=[AAA95050:01C8B69E] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/216 X-Sequence-Number: 30184 Alvaro Herrera wrote: > Greg Smith escribió: >> On Thu, 15 May 2008, Pavan Deolasee wrote: >> >>> I had suggested in the past that whenever we set hint bits for a tuple, >>> we should check all other tuples in the page and set their hint bits >>> too to avoid multiple writes of the same page. I guess the idea got >>> rejected because of lack of benchmarks to prove the benefit. >> >> From glancing at http://www.postgresql.org/docs/faqs.TODO.html I got the >> impression the idea was to have the background writer get involved to >> help with this particular situation. > > The problem is that the bgwriter does not understand about the content > of the pages it is writing -- they're opaque pages for all it knows. So > it cannot touch the hint bits. We know what kind of a relation we're dealing with in ReadBuffer, so we could add a flag to BufferDesc to mark heap pages. > If we had the bitmask in a separate map fork, this could be cheap. I don't buy that. The point of a hint bit is that it's right there along with the tuple you're looking at. If you have to look at a separate buffer, you might as well just look at clog. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com From matthew@flymine.org Thu May 15 15:17:54 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 8301E2E008B for ; Thu, 15 May 2008 12:17:54 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 76238-07 for ; Thu, 15 May 2008 12:17:34 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from ppsw-0.csi.cam.ac.uk (ppsw-0.csi.cam.ac.uk [131.111.8.130]) by developer.postgresql.org (Postfix) with ESMTP id EAFB82E0089 for ; Thu, 15 May 2008 12:17:33 -0300 (ADT) X-Cam-SpamDetails: Not scanned X-Cam-AntiVirus: No virus found X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from flymine.sysbiol.cam.ac.uk ([131.111.60.120]:54888 helo=flymine.flymine.org) by ppsw-0.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.130]:25) with esmtp id 1JwfCz-0007ga-17 (Exim 4.67) for pgsql-performance@postgresql.org (return-path ); Thu, 15 May 2008 16:17:29 +0100 Received: from host103 ([192.168.128.103] helo=aragorn.flymine.org ident=Debian-exim) by flymine.flymine.org with esmtp (Exim 4.12) id 1JwfCz-0004cI-00 for pgsql-performance@postgresql.org; Thu, 15 May 2008 16:17:29 +0100 Received: from mnw21 (helo=localhost) by aragorn.flymine.org with local-esmtp (Exim 4.69) (envelope-from ) id 1JwfCz-00041H-8J for pgsql-performance@postgresql.org; Thu, 15 May 2008 16:17:29 +0100 Date: Thu, 15 May 2008 16:17:29 +0100 (BST) From: Matthew Wakeling X-X-Sender: mnw21@aragorn.flymine.org To: pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) In-Reply-To: <482C51F4.9070809@enterprisedb.com> Message-ID: References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <482C320F.9070908@enterprisedb.com> <482C51F4.9070809@enterprisedb.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/217 X-Sequence-Number: 30185 On Thu, 15 May 2008, Heikki Linnakangas wrote: > There's not much point optimizing something that only helps with aborted > transactions. That's fair enough, but this list method is likely to speed up index writes anyway. > The general problem with any idea that involves keeping a list of changes > made in a transaction is that that list will grow big during bulk loads, so > you'll have to overflow to disk or abandon the list approach. Which means > that it won't help with bulk loads. Yeah, it wouldn't be a list of changes for the transaction, it would be a list of changes since the last checkpoint. Keeping data in memory for the length of the transaction is doomed to failure, because there is no bound on its size, so bulk loads are still going to miss out on hint optimisation. Matthew -- for a in past present future; do for b in clients employers associates relatives neighbours pets; do echo "The opinions here in no way reflect the opinions of my $a $b." done; done From alvherre@commandprompt.com Thu May 15 15:49:50 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 2E1492E0047 for ; Thu, 15 May 2008 12:49:50 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 08238-07 for ; Thu, 15 May 2008 12:49:45 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from lists.commandprompt.com (host-159.commandprompt.net [207.173.203.159]) by developer.postgresql.org (Postfix) with ESMTP id C9D3B2E002D for ; Thu, 15 May 2008 12:49:45 -0300 (ADT) Received: from perhan.alvh.no-ip.org (200-126-123-196.bk8-dsl.surnet.cl [200.126.123.196]) (authenticated bits=0) by lists.commandprompt.com (8.13.8/8.13.8) with ESMTP id m4FFodtE007600 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 15 May 2008 08:50:41 -0700 Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 00D2C47C5E; Thu, 15 May 2008 11:49:32 -0400 (CLT) Date: Thu, 15 May 2008 11:49:32 -0400 From: Alvaro Herrera To: Heikki Linnakangas Cc: Greg Smith , Pavan Deolasee , pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) Message-ID: <20080515154932.GB8221@alvh.no-ip.org> References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <2e78013d0805141940x50c3f51u439019e8e592959@mail.gmail.com> <20080515144106.GA8221@alvh.no-ip.org> <482C53A6.2030802@enterprisedb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <482C53A6.2030802@enterprisedb.com> User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0 (lists.commandprompt.com [207.173.203.159]); Thu, 15 May 2008 08:50:41 -0700 (PDT) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/221 X-Sequence-Number: 30189 Heikki Linnakangas escribió: > Alvaro Herrera wrote: >> The problem is that the bgwriter does not understand about the content >> of the pages it is writing -- they're opaque pages for all it knows. So >> it cannot touch the hint bits. > > We know what kind of a relation we're dealing with in ReadBuffer, so we > could add a flag to BufferDesc to mark heap pages. Hmm, I was thinking that it would need access to the catalogs to know where the tuples are, but that's certainly not true, so perhaps it could be made to work. >> If we had the bitmask in a separate map fork, this could be cheap. > > I don't buy that. The point of a hint bit is that it's right there along > with the tuple you're looking at. If you have to look at a separate > buffer, you might as well just look at clog. True -- I was confusing this with the idea of having the tuple MVCC header (xmin, xmax, etc) in a separate fork, which would make the idea of index-only scans more feasible at the expense of seqscans. -- Alvaro Herrera http://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support From alvherre@commandprompt.com Thu May 15 15:52:55 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id EC35C2E0056 for ; Thu, 15 May 2008 12:52:55 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 10092-02 for ; Thu, 15 May 2008 12:52:41 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from lists.commandprompt.com (host-159.commandprompt.net [207.173.203.159]) by developer.postgresql.org (Postfix) with ESMTP id 3E6E12E002D for ; Thu, 15 May 2008 12:52:40 -0300 (ADT) Received: from perhan.alvh.no-ip.org (200-126-123-196.bk8-dsl.surnet.cl [200.126.123.196]) (authenticated bits=0) by lists.commandprompt.com (8.13.8/8.13.8) with ESMTP id m4FFrcKL007740 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 15 May 2008 08:53:40 -0700 Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 18D1747C5E; Thu, 15 May 2008 11:52:32 -0400 (CLT) Date: Thu, 15 May 2008 11:52:32 -0400 From: Alvaro Herrera To: Matthew Wakeling Cc: pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) Message-ID: <20080515155232.GC8221@alvh.no-ip.org> References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0 (lists.commandprompt.com [207.173.203.159]); Thu, 15 May 2008 08:53:40 -0700 (PDT) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/222 X-Sequence-Number: 30190 Matthew Wakeling wrote: Aside from the rest of commentary, a slight clarification: > So, as I understand it, Postgres works like this: > > 1. You begin a transaction. Postgres writes an entry into pg_clog. Starting a transaction does not write anything to pg_clog. -- Alvaro Herrera http://www.CommandPrompt.com/ The PostgreSQL Company - Command Prompt, Inc. From tgl@sss.pgh.pa.us Thu May 15 16:19:46 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 0CAE72E004F for ; Thu, 15 May 2008 13:19:46 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 21193-04 for ; Thu, 15 May 2008 13:19:29 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by developer.postgresql.org (Postfix) with ESMTP id 136F52E002D for ; Thu, 15 May 2008 13:19:28 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m4FGJELU006228; Thu, 15 May 2008 12:19:14 -0400 (EDT) To: Alvaro Herrera cc: Heikki Linnakangas , Greg Smith , Pavan Deolasee , pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) In-reply-to: <20080515154932.GB8221@alvh.no-ip.org> References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <2e78013d0805141940x50c3f51u439019e8e592959@mail.gmail.com> <20080515144106.GA8221@alvh.no-ip.org> <482C53A6.2030802@enterprisedb.com> <20080515154932.GB8221@alvh.no-ip.org> Comments: In-reply-to Alvaro Herrera message dated "Thu, 15 May 2008 11:49:32 -0400" Date: Thu, 15 May 2008 12:19:14 -0400 Message-ID: <6227.1210868354@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/224 X-Sequence-Number: 30192 Alvaro Herrera writes: > Heikki Linnakangas escribió: >> We know what kind of a relation we're dealing with in ReadBuffer, so we >> could add a flag to BufferDesc to mark heap pages. > Hmm, I was thinking that it would need access to the catalogs to know > where the tuples are, but that's certainly not true, so perhaps it could > be made to work. The issue in my mind is not so much could bgwriter physically do it as that it's a violation of module layering. That has real consequences, like potential for deadlocks. It'll become particularly pressing if we go forward with the plans to get rid of the separate dedicated buffers for pg_clog etc and have them work in the main shared-buffer pool. regards, tom lane From Robert.Lor@Sun.COM Thu May 15 16:53:48 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id C03B62E0052 for ; Thu, 15 May 2008 13:53:48 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 40148-02-3 for ; Thu, 15 May 2008 13:53:39 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sca-es-mail-1.sun.com (sca-es-mail-1.Sun.COM [192.18.43.132]) by developer.postgresql.org (Postfix) with ESMTP id 224382E007B for ; Thu, 15 May 2008 13:53:26 -0300 (ADT) Received: from fe-sfbay-09.sun.com ([192.18.43.129]) by sca-es-mail-1.sun.com (8.13.7+Sun/8.12.9) with ESMTP id m4FGrOG3022602 for ; Thu, 15 May 2008 09:53:24 -0700 (PDT) Received: from conversion-daemon.fe-sfbay-09.sun.com by fe-sfbay-09.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) id <0K0X00H014JZNN00@fe-sfbay-09.sun.com> (original mail from Robert.Lor@Sun.COM) for pgsql-performance@postgresql.org; Thu, 15 May 2008 09:53:24 -0700 (PDT) Received: from [192.168.1.108] ([70.253.94.223]) by fe-sfbay-09.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) with ESMTPSA id <0K0X00MY05KN6BA0@fe-sfbay-09.sun.com>; Thu, 15 May 2008 09:53:12 -0700 (PDT) Date: Thu, 15 May 2008 11:55:00 -0500 From: Robert Lor Subject: Re: I/O on select count(*) In-reply-to: <28324.1210834939@sss.pgh.pa.us> To: Tom Lane Cc: Jan de Visser , Greg Smith , Alvaro Herrera , pgsql-performance@postgresql.org Message-id: <482C6AE4.8020607@sun.com> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=ISO-8859-1 Content-transfer-encoding: 7BIT References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <1159c1e90805141938j5f85b490rb5c1cfdf9e428bce@mail.gmail.com> <28324.1210834939@sss.pgh.pa.us> User-Agent: Thunderbird 2.0.0.6 (X11/20071119) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/226 X-Sequence-Number: 30194 Tom Lane wrote: > It's certainly true that hint-bit updates cost something, but > quantifying how much isn't easy. Maybe we can instrument the code with DTrace probes to quantify the actual costs. I'm not familiar with the code, but if I know where to place the probes, I can easily do a quick test and provide the data. > The off-the-cuff answer is to do the > select count(*) twice and see how much cheaper the second one is. Doesn't seem the second run is cheaper as shown in the results below. The data came from the probes I've added recently. *************** Run #1 ********************** SQL Statement : select count(*) from accounts; Execution time : 1086.58 (ms) ============ Buffer Read Counts ============ Tablespace Database Table Count 1663 16384 1247 1 1663 16384 2600 1 1663 16384 2703 1 1663 16384 1255 2 1663 16384 2650 2 1663 16384 2690 3 1663 16384 2691 3 1663 16384 16397 8390 ======== Dirty Buffer Write Counts ========= Tablespace Database Table Count 1663 16384 16397 2865 Total buffer cache hits : 1932 Total buffer cache misses : 6471 Average read time from cache : 5638 (ns) Average read time from disk : 143371 (ns) Average write time to disk : 20368 (ns) *************** Run #2 ********************** SQL Statement : select count(*) from accounts; Execution time : 1115.94 (ms) ============ Buffer Read Counts ============ Tablespace Database Table Count 1663 16384 16397 8390 ======== Dirty Buffer Write Counts ========= Tablespace Database Table Count 1663 16384 16397 2865 Total buffer cache hits : 1931 Total buffer cache misses : 6459 Average read time from cache : 4357 (ns) Average read time from disk : 154127 (ns) Average write time to disk : 20368 (ns) -Robert From tgl@sss.pgh.pa.us Thu May 15 17:42:20 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id EAA212E004C for ; Thu, 15 May 2008 14:42:20 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 26096-10 for ; Thu, 15 May 2008 14:42:13 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by developer.postgresql.org (Postfix) with ESMTP id E5E072E0047 for ; Thu, 15 May 2008 14:42:14 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m4FHg9Nj008797; Thu, 15 May 2008 13:42:09 -0400 (EDT) To: Robert Lor cc: Jan de Visser , Greg Smith , Alvaro Herrera , pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) In-reply-to: <482C6AE4.8020607@sun.com> References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <1159c1e90805141938j5f85b490rb5c1cfdf9e428bce@mail.gmail.com> <28324.1210834939@sss.pgh.pa.us> <482C6AE4.8020607@sun.com> Comments: In-reply-to Robert Lor message dated "Thu, 15 May 2008 11:55:00 -0500" Date: Thu, 15 May 2008 13:42:09 -0400 Message-ID: <8796.1210873329@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/227 X-Sequence-Number: 30195 Robert Lor writes: > Tom Lane wrote: >> It's certainly true that hint-bit updates cost something, but >> quantifying how much isn't easy. > Maybe we can instrument the code with DTrace probes to quantify the > actual costs. Hmm, the problem would be trying to figure out what percentage of writes could be blamed solely on hint-bit updates and not any other change to the page. I don't think that the bufmgr currently keeps enough state to know that, but you could probably modify it easily enough, since callers distinguish MarkBufferDirty from SetBufferCommitInfoNeedsSave. Define another flag bit that's set only by the first, and test it during write-out. regards, tom lane From Robert.Lor@Sun.COM Thu May 15 21:21:40 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id E061A2E0059 for ; Thu, 15 May 2008 18:21:40 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 57412-03 for ; Thu, 15 May 2008 18:21:25 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sca-es-mail-1.sun.com (sca-es-mail-1.Sun.COM [192.18.43.132]) by developer.postgresql.org (Postfix) with ESMTP id 894532E005C for ; Thu, 15 May 2008 18:21:28 -0300 (ADT) Received: from fe-sfbay-10.sun.com ([192.18.43.129]) by sca-es-mail-1.sun.com (8.13.7+Sun/8.12.9) with ESMTP id m4FLLRD4000690 for ; Thu, 15 May 2008 14:21:27 -0700 (PDT) Received: from conversion-daemon.fe-sfbay-10.sun.com by fe-sfbay-10.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) id <0K0X00D01H9EUF00@fe-sfbay-10.sun.com> (original mail from Robert.Lor@Sun.COM) for pgsql-performance@postgresql.org; Thu, 15 May 2008 14:21:27 -0700 (PDT) Received: from [192.168.1.108] ([70.253.94.223]) by fe-sfbay-10.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) with ESMTPSA id <0K0X00K4THZN6GF0@fe-sfbay-10.sun.com>; Thu, 15 May 2008 14:21:25 -0700 (PDT) Date: Thu, 15 May 2008 16:23:10 -0500 From: Robert Lor Subject: Re: I/O on select count(*) In-reply-to: <8796.1210873329@sss.pgh.pa.us> To: Tom Lane Cc: Jan de Visser , Greg Smith , Alvaro Herrera , pgsql-performance@postgresql.org Message-id: <482CA9BE.8060204@sun.com> MIME-version: 1.0 Content-type: multipart/mixed; boundary="Boundary_(ID_zdOUaaWHuhpYcFf/LpOxag)" References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <1159c1e90805141938j5f85b490rb5c1cfdf9e428bce@mail.gmail.com> <28324.1210834939@sss.pgh.pa.us> <482C6AE4.8020607@sun.com> <8796.1210873329@sss.pgh.pa.us> User-Agent: Thunderbird 2.0.0.6 (X11/20071119) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/229 X-Sequence-Number: 30197 This is a multi-part message in MIME format. --Boundary_(ID_zdOUaaWHuhpYcFf/LpOxag) Content-type: text/plain; format=flowed; charset=ISO-8859-1 Content-transfer-encoding: 7BIT Tom Lane wrote: > Hmm, the problem would be trying to figure out what percentage of writes > could be blamed solely on hint-bit updates and not any other change to > the page. I don't think that the bufmgr currently keeps enough state to > know that, but you could probably modify it easily enough, since callers > distinguish MarkBufferDirty from SetBufferCommitInfoNeedsSave. Define > another flag bit that's set only by the first, and test it during > write-out. > Ok, I made a few changes to bufmgr per my understanding of your description above and with my limited understanding of the code. Patch is attached. Assuming the patch is correct, the effect of writes due to hint bits is quite significant. I collected the data below by runing pgbench in one terminal and psql on another to run the query. Is the data plausible? -Robert -------------- Backend PID : 16189 SQL Statement : select count(*) from accounts; Execution time : 17.33 sec ============ Buffer Read Counts ============ Tablespace Database Table Count 1663 16384 2600 1 1663 16384 2601 1 1663 16384 2615 1 1663 16384 1255 2 1663 16384 2602 2 1663 16384 2603 2 1663 16384 2616 2 1663 16384 2650 2 1663 16384 2678 2 1663 16384 1247 3 1663 16384 1249 3 1663 16384 2610 3 1663 16384 2655 3 1663 16384 2679 3 1663 16384 2684 3 1663 16384 2687 3 1663 16384 2690 3 1663 16384 2691 3 1663 16384 2703 4 1663 16384 1259 5 1663 16384 2653 5 1663 16384 2662 5 1663 16384 2663 5 1663 16384 2659 7 1663 16384 16397 8390 ======== Dirty Buffer Write Counts ========= Tablespace Database Table Count 1663 16384 16402 2 1663 16384 16394 11 1663 16384 16397 4771 ========== Hint Bits Write Counts ========== Tablespace Database Table Count 1663 16384 16397 4508 Total buffer cache hits : 732 Total buffer cache misses : 7731 Average read time from cache : 9136 (ns) Average read time from disk : 384201 (ns) Average write time to disk : 210709 (ns) Backend PID : 16189 SQL Statement : select count(*) from accounts; Execution time : 12.72 sec ============ Buffer Read Counts ============ Tablespace Database Table Count 1663 16384 16397 8392 ======== Dirty Buffer Write Counts ========= Tablespace Database Table Count 1663 16384 16394 6 1663 16384 16402 7 1663 16384 16397 2870 ========== Hint Bits Write Counts ========== Tablespace Database Table Count 1663 16384 16402 2 1663 16384 16397 2010 Total buffer cache hits : 606 Total buffer cache misses : 7786 Average read time from cache : 6949 (ns) Average read time from disk : 706288 (ns) Average write time to disk : 90426 (ns) --Boundary_(ID_zdOUaaWHuhpYcFf/LpOxag) Content-type: text/x-patch; name=hint-bits-test.patch Content-transfer-encoding: 7BIT Content-disposition: inline; filename=hint-bits-test.patch Index: bufmgr.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v retrieving revision 1.228 diff -u -3 -p -r1.228 bufmgr.c --- bufmgr.c 1 Jan 2008 19:45:51 -0000 1.228 +++ bufmgr.c 15 May 2008 20:56:38 -0000 @@ -42,6 +42,7 @@ #include "storage/smgr.h" #include "utils/resowner.h" #include "pgstat.h" +#include "pg_trace.h" /* Note: these two macros only work on shared buffers, not local ones! */ @@ -171,6 +172,7 @@ ReadBuffer_common(Relation reln, BlockNu if (isExtend) blockNum = smgrnblocks(reln->rd_smgr); + TRACE_POSTGRESQL_BUFFER_READ_START(blockNum, reln->rd_node.spcNode, reln->rd_node.dbNode, reln->rd_node.relNode, isLocalBuf); pgstat_count_buffer_read(reln); if (isLocalBuf) @@ -200,12 +202,16 @@ ReadBuffer_common(Relation reln, BlockNu { if (!isExtend) { + TRACE_POSTGRESQL_BUFFER_HIT(); /* Just need to update stats before we exit */ pgstat_count_buffer_hit(reln); if (VacuumCostActive) VacuumCostBalance += VacuumCostPageHit; + TRACE_POSTGRESQL_BUFFER_READ_DONE(blockNum, + reln->rd_node.spcNode, reln->rd_node.dbNode, + reln->rd_node.relNode, isLocalBuf, found); return BufferDescriptorGetBuffer(bufHdr); } @@ -257,6 +263,7 @@ ReadBuffer_common(Relation reln, BlockNu } while (!StartBufferIO(bufHdr, true)); } } + TRACE_POSTGRESQL_BUFFER_MISS(); /* * if we have gotten to this point, we have allocated a buffer for the @@ -324,6 +331,9 @@ ReadBuffer_common(Relation reln, BlockNu if (VacuumCostActive) VacuumCostBalance += VacuumCostPageMiss; + TRACE_POSTGRESQL_BUFFER_READ_DONE(blockNum, reln->rd_node.spcNode, + reln->rd_node.dbNode, reln->rd_node.relNode, isLocalBuf, found); + return BufferDescriptorGetBuffer(bufHdr); } @@ -466,6 +476,11 @@ BufferAlloc(Relation reln, * happens to be trying to split the page the first one got from * StrategyGetBuffer.) */ + + TRACE_POSTGRESQL_DIRTY_BUFFER_WRITE_START(blockNum, + reln->rd_node.spcNode, reln->rd_node.dbNode, + reln->rd_node.relNode); + if (LWLockConditionalAcquire(buf->content_lock, LW_SHARED)) { /* @@ -488,6 +503,11 @@ BufferAlloc(Relation reln, /* OK, do the I/O */ FlushBuffer(buf, NULL); LWLockRelease(buf->content_lock); + + TRACE_POSTGRESQL_DIRTY_BUFFER_WRITE_DONE( + blockNum, reln->rd_node.spcNode, + reln->rd_node.dbNode, reln->rd_node.relNode, + (oldFlags & BM_HINT_BITS_TEST)); } else { @@ -1734,6 +1754,10 @@ FlushBuffer(volatile BufferDesc *buf, SM buf->flags &= ~BM_JUST_DIRTIED; UnlockBufHdr(buf); + TRACE_POSTGRESQL_BUFFER_WRITE_START(buf->tag.blockNum, + reln->smgr_rnode.spcNode, reln->smgr_rnode.dbNode, + reln->smgr_rnode.relNode); + smgrwrite(reln, buf->tag.blockNum, (char *) BufHdrGetBlock(buf), @@ -1741,6 +1765,10 @@ FlushBuffer(volatile BufferDesc *buf, SM BufferFlushCount++; + TRACE_POSTGRESQL_BUFFER_WRITE_DONE(buf->tag.blockNum, + reln->smgr_rnode.spcNode, reln->smgr_rnode.dbNode, + reln->smgr_rnode.relNode, (buf->flags & BM_HINT_BITS_TEST)); + /* * Mark the buffer as clean (unless BM_JUST_DIRTIED has become set) and * end the io_in_progress state. @@ -2155,7 +2183,7 @@ SetBufferCommitInfoNeedsSave(Buffer buff Assert(bufHdr->refcount > 0); if (!(bufHdr->flags & BM_DIRTY) && VacuumCostActive) VacuumCostBalance += VacuumCostPageDirty; - bufHdr->flags |= (BM_DIRTY | BM_JUST_DIRTIED); + bufHdr->flags |= (BM_DIRTY | BM_JUST_DIRTIED | BM_HINT_BITS_TEST); UnlockBufHdr(bufHdr); } } @@ -2492,7 +2520,7 @@ TerminateBufferIO(volatile BufferDesc *b Assert(buf->flags & BM_IO_IN_PROGRESS); buf->flags &= ~(BM_IO_IN_PROGRESS | BM_IO_ERROR); if (clear_dirty && !(buf->flags & BM_JUST_DIRTIED)) - buf->flags &= ~(BM_DIRTY | BM_CHECKPOINT_NEEDED); + buf->flags &= ~(BM_DIRTY | BM_CHECKPOINT_NEEDED | BM_HINT_BITS_TEST); buf->flags |= set_flag_bits; UnlockBufHdr(buf); Index: buf_internals.h =================================================================== RCS file: /projects/cvsroot/pgsql/src/include/storage/buf_internals.h,v retrieving revision 1.95 diff -u -3 -p -r1.95 buf_internals.h --- buf_internals.h 1 Jan 2008 19:45:58 -0000 1.95 +++ buf_internals.h 15 May 2008 20:59:42 -0000 @@ -36,6 +36,7 @@ #define BM_JUST_DIRTIED (1 << 5) /* dirtied since write started */ #define BM_PIN_COUNT_WAITER (1 << 6) /* have waiter for sole pin */ #define BM_CHECKPOINT_NEEDED (1 << 7) /* must write for checkpoint */ +#define BM_HINT_BITS_TEST (1 << 8) /* test effect of writes due to hint bits */ typedef bits16 BufFlags; --Boundary_(ID_zdOUaaWHuhpYcFf/LpOxag)-- From james@mansionfamily.plus.com Thu May 15 22:07:17 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 499272E004A for ; Thu, 15 May 2008 19:07:17 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 74301-03 for ; Thu, 15 May 2008 19:07:10 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from ptb-relay03.plus.net (ptb-relay03.plus.net [212.159.14.214]) by developer.postgresql.org (Postfix) with ESMTP id 4F0BC2E0050 for ; Thu, 15 May 2008 19:07:14 -0300 (ADT) Received: from [80.229.150.39] (helo=pd600.barnhouse) by ptb-relay03.plus.net with esmtp (Exim) id 1JwlbP-00054z-MO; Thu, 15 May 2008 23:07:08 +0100 Received: from [192.168.0.87] (unknown [192.168.0.87]) by pd600.barnhouse (Postfix) with ESMTP id 3B5344E1C0D; Thu, 15 May 2008 23:13:08 +0100 (BST) Message-ID: <482CB528.9000600@mansionfamily.plus.com> Date: Thu, 15 May 2008 23:11:52 +0100 From: James Mansion Organization: MsgWare User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 To: Alvaro Herrera CC: Greg Smith , pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> In-Reply-To: <20080515020553.GN9838@alvh.no-ip.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Plusnet-Relay: 844e61e65e3e576622d7f9b0d79836c3 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/230 X-Sequence-Number: 30198 Alvaro Herrera wrote: > Hint bits are used to mark tuples as created and/or deleted by > transactions that are know committed or aborted. To determine the > visibility of a tuple without such bits set, you need to consult pg_clog > and possibly pg_subtrans, so it is an expensive check. On the other > So, how come there is this outstanding work to do, which will inevitably be done, and it hasn't been done until it is 'just too late' to avoid getting in the way of the query? The OP didn't suggest that he had just loaded the data. Also - is it the case that this only affects the case where updated pages were spilled during the transaction that changed them? ie, if we commit a transaction and there are changed rows still in the cache since their pages are not evicted yet, are the hint bits set immediately so that page is written just once? Seems this would be common in most OLTP systems. Heikki points out that the list might get big and need to be abandoned, but then you fall back to scheduling a clog scan that can apply the bits, which does what you have now, though hopefully in a way that fills slack disk IO rather than waiting for the read. Matthew says: 'it would be a list of changes since the last checkpoint' but I don't see why you can't start writing hints to in-memory pages as soon as the transaction ends. You might fall behind, but I doubt it with modern CPU speeds. I can't see why Pavan's suggestion to try to update as many of the bits as possible when a dirty page is evicted would be contentious. I do think this is something of interest to users, not just developers, since it may influence the way updates are processed where it is reasonable to do so in 'bite sized chunks' as a multipart workflow. From stark@enterprisedb.com Thu May 15 22:30:51 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 8B1602E004A for ; Thu, 15 May 2008 19:30:51 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 80251-10 for ; Thu, 15 May 2008 19:30:44 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from oxford.xeocode.com (87-127-95-198.no-dns-yet.enta.net [87.127.95.198]) by developer.postgresql.org (Postfix) with ESMTP id 31A5B2E0057 for ; Thu, 15 May 2008 19:30:48 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=oxford.xeocode.com) by oxford.xeocode.com with esmtp (Exim 4.69) (envelope-from ) id 1JwlyD-0001RA-JF; Thu, 15 May 2008 23:30:41 +0100 To: "Luke Lonergan" Cc: "Pavan Deolasee" , "Greg Smith" , "Alvaro Herrera" , Subject: Re: I/O on select count(*) In-Reply-To: (Luke Lonergan's message of "Thu\, 15 May 2008 10\:52\:01 +0800") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) X-Draft-From: ("nnimap+mail01.enterprisedb.com:INBOX.performance" 5650) References: From: Gregory Stark Organization: EnterpriseDB Date: Thu, 15 May 2008 23:30:41 +0100 Message-ID: <87hcczqjxq.fsf@oxford.xeocode.com> 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-Archive-Number: 200805/231 X-Sequence-Number: 30199 "Luke Lonergan" writes: > BTW =AD we=B9ve removed HINT bit checking in Greenplum DB and improved the > visibility caching which was enough to provide performance at the same le= vel > as with the HINT bit optimization, but avoids this whole =B3write the dat= a, > write it to the log also, then write it again just for good measure=B2 > behavior. > > For people doing data warehousing work like the poster, this Postgres > behavior is miserable. It should be fixed for 8.4 for sure (volunteers?) For people doing data warehousing I would think the trick would be to do something like what we do to avoid WAL logging for tables created in the sa= me transaction.=20 That is, if you're loading a lot of data at the same time then all of that data is going to be aborted or committed and that will happen at the same time. Ideally we would find a way to insert the data with the hint bits already set to committed and mark the section of the table as being only provisionally extended so other transactions wouldn't even look at those pa= ges until the transaction commits. This is similar to the abortive attempt to have the abovementioned WAL logg= ing trick insert the records pre-frozen. I recall there were problems with that idea though but I don't recall if they were insurmountable or just required more work. --=20 Gregory Stark EnterpriseDB http://www.enterprisedb.com Ask me about EnterpriseDB's Slony Replication support! From Kevin.Grittner@wicourts.gov Thu May 15 22:38:41 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 0A1712E0035 for ; Thu, 15 May 2008 19:38:41 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 84094-10 for ; Thu, 15 May 2008 19:38:34 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from gwmta.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) by developer.postgresql.org (Postfix) with ESMTP id 3233A2E0031 for ; Thu, 15 May 2008 19:38:38 -0300 (ADT) Received: from Courts-MTA by gwmta.wicourts.gov with Novell_GroupWise; Thu, 15 May 2008 17:38:36 -0500 Message-Id: <482C753E.EE98.0025.0@wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 7.0.3 Date: Thu, 15 May 2008 17:38:27 -0500 From: "Kevin Grittner" To: "Alvaro Herrera" , "James Mansion" Cc: "Greg Smith" , Subject: Re: I/O on select count(*) References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <482CB528.9000600@mansionfamily.plus.com> In-Reply-To: <482CB528.9000600@mansionfamily.plus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/232 X-Sequence-Number: 30200 >>> On Thu, May 15, 2008 at 5:11 PM, in message <482CB528.9000600@mansionfamily.plus.com>, James Mansion wrote: > Alvaro Herrera wrote: >> Hint bits are used to mark tuples as created and/or deleted by >> transactions that are know committed or aborted. To determine the >> visibility of a tuple without such bits set, you need to consult pg_clog >> and possibly pg_subtrans, so it is an expensive check. On the other >> > So, how come there is this outstanding work to do, which will inevitably > be done, and it > hasn't been done until it is 'just too late' to avoid getting in the way > of the query? There has been discussion from time to time about setting the hint bits for tuple inserts which occur within the same database transaction as the creation of the table into which they're being inserted. That would allow people to cover many of the bulk load situations. I don't see it on the task list. (I would also argue that there is little information lost, even from a forensic perspective, to writing such rows as "frozen".) Is this idea done, dead, or is someone working on it? If we could set hint bits on dirty buffer pages after the commit, we'd cover the OLTP situation. In many situations, there is a bigger OS cache than PostgreSQL shared memory, and an attempt to set the bits soon after the commit would coalesce the two writes into one physical write using RAM-based access, which would be almost as good. I don't know if it's feasible to try to do that after the pages have moved from the PostgreSQL cache to the OS cache, but it would likely be a performance win. If we are going to burden any requester process with the job of setting the hint bits, it would typically be better to burden the one doing the data modification rather than some random thread later trying to read data from the table. Of course, getting work off the requester processes onto some background worker process is generally even better. -Kevin From gsmith@gregsmith.com Fri May 16 18:06:10 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 514122E0047 for ; Fri, 16 May 2008 15:06:10 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 91630-07 for ; Fri, 16 May 2008 15:05:54 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from westnet.com (westnet.com [216.187.52.2]) by developer.postgresql.org (Postfix) with ESMTP id B61DB2E0031 for ; Fri, 16 May 2008 15:05:55 -0300 (ADT) Received: from westnet.com (localhost [127.0.0.1]) by westnet.com (8.14.0/8.14.0) with ESMTP id m4GI5o7R015823; Fri, 16 May 2008 14:05:50 -0400 (EDT) Received: from localhost (gsmith@localhost) by westnet.com (8.14.0/8.13.2/Submit) with ESMTP id m4GI5nTL015815; Fri, 16 May 2008 14:05:50 -0400 (EDT) X-Authentication-Warning: westnet.com: gsmith owned process doing -bs Date: Fri, 16 May 2008 14:05:49 -0400 (EDT) From: Greg Smith X-X-Sender: gsmith@westnet.com To: Alvaro Herrera cc: Matthew Wakeling , pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) In-Reply-To: <20080515155232.GC8221@alvh.no-ip.org> Message-ID: References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <20080515155232.GC8221@alvh.no-ip.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/248 X-Sequence-Number: 30216 On Thu, 15 May 2008, Alvaro Herrera wrote: > Starting a transaction does not write anything to pg_clog. For Matt and others, some details here are in src/backend/access/transam/README: "pg_clog records the commit status for each transaction that has been assigned an XID." "Transactions and subtransactions are assigned permanent XIDs only when/if they first do something that requires one --- typically, insert/update/delete a tuple, though there are a few other places that need an XID assigned." After reading the code and that documentation a bit, the part I'm still not sure about is whether the CLOG entry is created when the XID is assigned and then kept current as the state changes, or whether that isn't even in CLOG until the transaction is committed. It seems like the latter, but there's some ambiguity in the wording and too many code paths for me to map right now. From simon@2ndquadrant.com Fri May 16 18:22:41 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 10EE32E0049 for ; Fri, 16 May 2008 15:22:41 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 02459-06 for ; Fri, 16 May 2008 15:22:31 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from outmail128171.authsmtp.com (outmail128171.authsmtp.com [62.13.128.171]) by developer.postgresql.org (Postfix) with ESMTP id 643512E002E for ; Fri, 16 May 2008 15:22:33 -0300 (ADT) Received: from mail-c188.authsmtp.com (mail-c188.authsmtp.com [62.13.128.25]) by punt2.authsmtp.com (8.13.8/8.13.8/Kp) with ESMTP id m4GIMFfT076313; Fri, 16 May 2008 19:22:15 +0100 (BST) Received: from [192.168.0.6] (85-211-226-243.dyn.gotadsl.co.uk [85.211.226.243]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id m4GIME2i046502; Fri, 16 May 2008 19:22:14 +0100 (BST) Subject: Re: I/O on select count(*) From: Simon Riggs To: Greg Smith Cc: Alvaro Herrera , Matthew Wakeling , pgsql-performance@postgresql.org In-Reply-To: References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <20080515155232.GC8221@alvh.no-ip.org> Content-Type: text/plain Date: Fri, 16 May 2008 19:23:55 +0100 Message-Id: <1210962235.18922.109.camel@ebony.site> Mime-Version: 1.0 X-Mailer: Evolution 2.12.0 Content-Transfer-Encoding: 7bit X-Server-Quench: 02563408-2375-11dd-aecc-001871e930f4 X-AuthRoute: OCdxZQATClZOTQEd DAteCiNZVAwpPBRK HVkIKg5MJUcNSQVJ NksachtFaQNbYFhI HGQLW1xEUVR7W2F/ ag4fZQBDYEtPQQdo VlZLRlFNFgB3AVJc AmlnL2xwLgVCfntw ZwhjWHRcEkR4cEB+ Rk5cCG8FYmJ9aWFL BF0JIlAHbQNKfxdC awV2V3NbZStlM3Bw LDceBR4WBxBqYAUS ZUkKKxoJTEIGFSJ0 TBcfGylvXwxt X-Authentic-SMTP: 61633235383639.cat.dmpriest.net.uk:953/Kp X-Report-SPAM: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-Virus-Status: No virus detected - but ensure you scan with your own anti-virus system! X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/251 X-Sequence-Number: 30219 On Fri, 2008-05-16 at 14:05 -0400, Greg Smith wrote: > After reading the code and that documentation a bit, the part I'm > still not sure about is whether the CLOG entry is created when the XID > is assigned and then kept current as the state changes, or whether > that isn't even in CLOG until the transaction is committed. It seems > like the latter, but there's some ambiguity in the wording and too > many code paths for me to map right now. Alvaro already said this, I thought? The clog is updated only at sub or main transaction end, thank goodness. When the transactionid is assigned the page of the clog that contains that transactionid is checked to see if it already exists and if not, it is initialised. -- Simon Riggs www.2ndQuadrant.com PostgreSQL Training, Services and Support From alvherre@commandprompt.com Fri May 16 20:15:46 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 69DF92E0033 for ; Fri, 16 May 2008 17:15:46 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 70863-08 for ; Fri, 16 May 2008 17:15:40 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from lists.commandprompt.com (host-159.commandprompt.net [207.173.203.159]) by developer.postgresql.org (Postfix) with ESMTP id 8CC122E002C for ; Fri, 16 May 2008 17:15:37 -0300 (ADT) Received: from perhan.alvh.no-ip.org (200-126-123-196.bk8-dsl.surnet.cl [200.126.123.196]) (authenticated bits=0) by lists.commandprompt.com (8.13.8/8.13.8) with ESMTP id m4GKGWxI012650 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 16 May 2008 13:16:35 -0700 Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 607AD47C64; Fri, 16 May 2008 16:15:28 -0400 (CLT) Date: Fri, 16 May 2008 16:15:28 -0400 From: Alvaro Herrera To: Greg Smith Cc: Matthew Wakeling , pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) Message-ID: <20080516201528.GJ13061@alvh.no-ip.org> References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <20080515155232.GC8221@alvh.no-ip.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0 (lists.commandprompt.com [207.173.203.159]); Fri, 16 May 2008 13:16:36 -0700 (PDT) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/255 X-Sequence-Number: 30223 Greg Smith wrote: > After reading the code and that documentation a bit, the part I'm still > not sure about is whether the CLOG entry is created when the XID is > assigned and then kept current as the state changes, or whether that > isn't even in CLOG until the transaction is committed. It seems like the > latter, but there's some ambiguity in the wording and too many code paths > for me to map right now. pg_clog is allocated in pages of 8kB apiece(*). On allocation, pages are zeroed, which is the bit pattern for "transaction in progress". So when a transaction starts, it only needs to ensure that the pg_clog page that corresponds to it is allocated, but it need not write anything to it. (*) Each transaction needs 2 bits, so on a 8 kB page there is space for 4 transactions/byte * 8 pages * 1kB/page = 32k transactions. -- Alvaro Herrera http://www.CommandPrompt.com/ The PostgreSQL Company - Command Prompt, Inc. From alvherre@commandprompt.com Fri May 16 21:01:09 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 33E252E0072 for ; Fri, 16 May 2008 18:01:09 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 99685-03 for ; Fri, 16 May 2008 18:01:00 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from lists.commandprompt.com (host-159.commandprompt.net [207.173.203.159]) by developer.postgresql.org (Postfix) with ESMTP id 9B7262E0043 for ; Fri, 16 May 2008 18:01:03 -0300 (ADT) Received: from perhan.alvh.no-ip.org (200-126-123-196.bk8-dsl.surnet.cl [200.126.123.196]) (authenticated bits=0) by lists.commandprompt.com (8.13.8/8.13.8) with ESMTP id m4GL1tj3013827 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 16 May 2008 14:01:57 -0700 Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id CA28347C64; Fri, 16 May 2008 17:00:50 -0400 (CLT) Date: Fri, 16 May 2008 17:00:50 -0400 From: Alvaro Herrera To: Greg Smith Cc: Matthew Wakeling , pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) Message-ID: <20080516210050.GL13061@alvh.no-ip.org> References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <20080515155232.GC8221@alvh.no-ip.org> <20080516201528.GJ13061@alvh.no-ip.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080516201528.GJ13061@alvh.no-ip.org> User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0 (lists.commandprompt.com [207.173.203.159]); Fri, 16 May 2008 14:01:57 -0700 (PDT) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/257 X-Sequence-Number: 30225 Alvaro Herrera wrote: > pg_clog is allocated in pages of 8kB apiece(*). On allocation, pages are > zeroed, which is the bit pattern for "transaction in progress". So when > a transaction starts, it only needs to ensure that the pg_clog page that > corresponds to it is allocated, but it need not write anything to it. Of course, in 8.3 it's not when the transaction starts, but when the Xid is assigned (i.e. when the transaction first calls a read-write command). In previous versions it happens when the first snapshot is taken (i.e. normally on the first command of any type, with very few exceptions.) -- Alvaro Herrera http://www.CommandPrompt.com/ The PostgreSQL Company - Command Prompt, Inc. From tgl@sss.pgh.pa.us Sat May 17 02:45:15 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id C466C2E0031 for ; Fri, 16 May 2008 23:45:15 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 24624-09 for ; Fri, 16 May 2008 23:45:06 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by developer.postgresql.org (Postfix) with ESMTP id 9A9062E002E for ; Fri, 16 May 2008 23:45:12 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m4H2j2kT018383; Fri, 16 May 2008 22:45:02 -0400 (EDT) To: Alvaro Herrera cc: Greg Smith , Matthew Wakeling , pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) In-reply-to: <20080516201528.GJ13061@alvh.no-ip.org> References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <20080515155232.GC8221@alvh.no-ip.org> <20080516201528.GJ13061@alvh.no-ip.org> Comments: In-reply-to Alvaro Herrera message dated "Fri, 16 May 2008 16:15:28 -0400" Date: Fri, 16 May 2008 22:45:02 -0400 Message-ID: <18382.1210992302@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/261 X-Sequence-Number: 30229 Alvaro Herrera writes: > Greg Smith wrote: >> After reading the code and that documentation a bit, the part I'm still >> not sure about is whether the CLOG entry is created when the XID is >> assigned and then kept current as the state changes, or whether that >> isn't even in CLOG until the transaction is committed. > pg_clog is allocated in pages of 8kB apiece(*). On allocation, pages are > zeroed, which is the bit pattern for "transaction in progress". So when > a transaction starts, it only needs to ensure that the pg_clog page that > corresponds to it is allocated, but it need not write anything to it. One additional point: this means that one transaction in every 32K writing transactions *does* have to do extra work when it assigns itself an XID, namely create and zero out the next page of pg_clog. And that doesn't just slow down the transaction in question, but the next few guys that would like an XID but arrive on the scene while the zeroing-out is still in progress. This probably contributes to the behavior that Simon and Josh regularly complain about, that our transaction execution time is subject to unpredictable spikes. I'm not sure how to get rid of it though. regards, tom lane From jgh@wizmail.org Sat May 17 13:14:04 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 5ED892E0041 for ; Sat, 17 May 2008 10:14:04 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 95962-08 for ; Sat, 17 May 2008 10:13:53 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from wizmail.org (wizmail.org [217.146.104.199]) by developer.postgresql.org (Postfix) with ESMTP id 765E92E0033 for ; Sat, 17 May 2008 10:13:58 -0300 (ADT) Received: from ebony.jgh.adsl.wizards.co.uk ([217.146.123.59]) (from_AS 16353) by wizmail.org with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.67) id 1JxMEW-00064k-IK for pgsql-performance@postgresql.org (return-path ); Sat, 17 May 2008 13:13:56 +0000 Message-ID: <482EDA10.5060603@wizmail.org> Date: Sat, 17 May 2008 14:13:52 +0100 From: Jeremy Harris User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.12) Gecko/20080226 Fedora/2.0.0.12-1.fc7 Thunderbird/2.0.0.12 Mnenhy/0.7.5.0 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <20080515155232.GC8221@alvh.no-ip.org> <20080516201528.GJ13061@alvh.no-ip.org> <18382.1210992302@sss.pgh.pa.us> In-Reply-To: <18382.1210992302@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/262 X-Sequence-Number: 30230 Tom Lane wrote: > One additional point: this means that one transaction in every 32K > writing transactions *does* have to do extra work when it assigns itself > an XID, namely create and zero out the next page of pg_clog. And that > doesn't just slow down the transaction in question, but the next few > guys that would like an XID but arrive on the scene while the > zeroing-out is still in progress. > > This probably contributes to the behavior that Simon and Josh regularly > complain about, that our transaction execution time is subject to > unpredictable spikes. I'm not sure how to get rid of it though. A thread maintaining a pool of assigned and cleared pg_clog pages, ahead of the immediate need? Possibly another job for an existing daemon thread. - Jeremy From gsmith@gregsmith.com Sun May 18 05:48:13 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 9DD002E00AE for ; Sun, 18 May 2008 02:48:13 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 21017-09 for ; Sun, 18 May 2008 02:48:03 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from westnet.com (westnet.com [216.187.52.2]) by developer.postgresql.org (Postfix) with ESMTP id 177192E009A for ; Sun, 18 May 2008 02:28:27 -0300 (ADT) Received: from westnet.com (localhost [127.0.0.1]) by westnet.com (8.14.0/8.14.0) with ESMTP id m4I5SQB5014528 for ; Sun, 18 May 2008 01:28:26 -0400 (EDT) Received: from localhost (gsmith@localhost) by westnet.com (8.14.0/8.13.2/Submit) with ESMTP id m4I5SQH8014525 for ; Sun, 18 May 2008 01:28:26 -0400 (EDT) X-Authentication-Warning: westnet.com: gsmith owned process doing -bs Date: Sun, 18 May 2008 01:28:26 -0400 (EDT) From: Greg Smith X-X-Sender: gsmith@westnet.com To: pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) In-Reply-To: <18382.1210992302@sss.pgh.pa.us> Message-ID: References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <20080515155232.GC8221@alvh.no-ip.org> <20080516201528.GJ13061@alvh.no-ip.org> <18382.1210992302@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/263 X-Sequence-Number: 30231 I just collected all the good internals information included in this thread and popped it onto http://wiki.postgresql.org/wiki/Hint_Bits where I'll continue to hack away at the text until it's readable. Thanks to everyone who answered my questions here, that's good progress toward clearing up a very underdocumented area. I note a couple of potential TODO items not on the official list yet that came up during this discussion: -Smooth latency spikes when switching commit log pages by preallocating cleared pages before they are needed -Improve bulk loading by setting "frozen" hint bits for tuple inserts which occur within the same database transaction as the creation of the table into which they're being inserted Did I miss anything? I think everything brought up falls either into one of those two or the existing "Consider having the background writer update the transaction status hint bits..." TODO. -- * Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD From matthew@flymine.org Mon May 19 12:32:44 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 7C6EF2E0032 for ; Mon, 19 May 2008 09:32:44 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 72000-05 for ; Mon, 19 May 2008 09:32:35 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from ppsw-9.csi.cam.ac.uk (ppsw-9.csi.cam.ac.uk [131.111.8.139]) by developer.postgresql.org (Postfix) with ESMTP id 909D22E0031 for ; Mon, 19 May 2008 09:32:39 -0300 (ADT) X-Cam-SpamDetails: Not scanned X-Cam-AntiVirus: No virus found X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from flymine.sysbiol.cam.ac.uk ([131.111.60.120]:57350 helo=flymine.flymine.org) by ppsw-9.csi.cam.ac.uk (ppsw.cam.ac.uk [131.111.8.139]:25) with esmtp id 1Jy4XZ-0005YH-TN (Exim 4.67) for pgsql-performance@postgresql.org (return-path ); Mon, 19 May 2008 13:32:33 +0100 Received: from host103 ([192.168.128.103] helo=aragorn.flymine.org ident=Debian-exim) by flymine.flymine.org with esmtp (Exim 4.12) id 1Jy4XZ-0000sC-00 for pgsql-performance@postgresql.org; Mon, 19 May 2008 13:32:33 +0100 Received: from mnw21 (helo=localhost) by aragorn.flymine.org with local-esmtp (Exim 4.69) (envelope-from ) id 1Jy4XY-0002uS-Tk for pgsql-performance@postgresql.org; Mon, 19 May 2008 13:32:32 +0100 Date: Mon, 19 May 2008 13:32:32 +0100 (BST) From: Matthew Wakeling X-X-Sender: mnw21@aragorn.flymine.org To: pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) In-Reply-To: <18382.1210992302@sss.pgh.pa.us> Message-ID: References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <20080515155232.GC8221@alvh.no-ip.org> <20080516201528.GJ13061@alvh.no-ip.org> <18382.1210992302@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/265 X-Sequence-Number: 30233 > Alvaro Herrera writes: >> pg_clog is allocated in pages of 8kB apiece(*). On allocation, pages are >> zeroed, which is the bit pattern for "transaction in progress". So when >> a transaction starts, it only needs to ensure that the pg_clog page that >> corresponds to it is allocated, but it need not write anything to it. Yeah, that's pretty-much how I imagined it would be. Nice and compact. I would imagine that if there are only a few transactions, doing the pg_clog lookup would be remarkably quick. However, once there have been a bazillion transactions, with tuples pointing to the whole range of them, it would degenerate into having to perform an extra seek for each tuple, and that's why you added the hint bits. On Fri, 16 May 2008, Tom Lane wrote: > One additional point: this means that one transaction in every 32K > writing transactions *does* have to do extra work when it assigns itself > an XID, namely create and zero out the next page of pg_clog. And that > doesn't just slow down the transaction in question, but the next few > guys that would like an XID but arrive on the scene while the > zeroing-out is still in progress. > > This probably contributes to the behavior that Simon and Josh regularly > complain about, that our transaction execution time is subject to > unpredictable spikes. I'm not sure how to get rid of it though. Does it really take that long to zero out 8kB of RAM? I thought CPUs were really quick at doing that! Anyway, the main thing you need to avoid is all the rest of the transactions waiting for the new pg_clog page. The trick is to generate the new page early, outside any locks on existing pages. It doesn't necessarily need to be done by a daemon thread at all. Matthew -- I'm NOT paranoid! Which of my enemies told you this? From bruce@momjian.us Mon May 19 14:54:18 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 4A4BA2E0058 for ; Mon, 19 May 2008 11:54:18 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 34269-02 for ; Mon, 19 May 2008 11:54:04 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from momjian.us (momjian.us [70.90.9.53]) by developer.postgresql.org (Postfix) with ESMTP id 0BB2C2E0045 for ; Mon, 19 May 2008 11:54:09 -0300 (ADT) Received: (from bruce@localhost) by momjian.us (8.11.6/8.11.6) id m4JEs6400890; Mon, 19 May 2008 10:54:06 -0400 (EDT) From: Bruce Momjian Message-Id: <200805191454.m4JEs6400890@momjian.us> Subject: Re: I/O on select count(*) In-Reply-To: To: Matthew Wakeling Date: Mon, 19 May 2008 10:54:06 -0400 (EDT) CC: pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL124 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="US-ASCII" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/266 X-Sequence-Number: 30234 Matthew Wakeling wrote: > On Fri, 16 May 2008, Tom Lane wrote: > > One additional point: this means that one transaction in every 32K > > writing transactions *does* have to do extra work when it assigns itself > > an XID, namely create and zero out the next page of pg_clog. And that > > doesn't just slow down the transaction in question, but the next few > > guys that would like an XID but arrive on the scene while the > > zeroing-out is still in progress. > > > > This probably contributes to the behavior that Simon and Josh regularly > > complain about, that our transaction execution time is subject to > > unpredictable spikes. I'm not sure how to get rid of it though. > > Does it really take that long to zero out 8kB of RAM? I thought CPUs were > really quick at doing that! Yea, that was my assumption too. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. + From tgl@sss.pgh.pa.us Mon May 19 15:38:07 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 9BBBD2E0032 for ; Mon, 19 May 2008 12:38:07 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 67001-08 for ; Mon, 19 May 2008 12:38:02 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by developer.postgresql.org (Postfix) with ESMTP id 3F4432E003B for ; Mon, 19 May 2008 12:38:01 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m4JFbwSL005698; Mon, 19 May 2008 11:37:58 -0400 (EDT) To: Bruce Momjian cc: Matthew Wakeling , pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) In-reply-to: <200805191454.m4JEs6400890@momjian.us> References: <200805191454.m4JEs6400890@momjian.us> Comments: In-reply-to Bruce Momjian message dated "Mon, 19 May 2008 10:54:06 -0400" Date: Mon, 19 May 2008 11:37:58 -0400 Message-ID: <5697.1211211478@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/267 X-Sequence-Number: 30235 Bruce Momjian writes: > Matthew Wakeling wrote: >> Does it really take that long to zero out 8kB of RAM? I thought CPUs were >> really quick at doing that! > Yea, that was my assumption too. You have to write the page (to be sure there is space for it on disk) not only zero it. This design is kind of a holdover, though, from back when we had one ever-growing clog file. Today I'd be inclined to think about managing it more like pg_xlog, ie, have some background process pre-create a whole segment file at a time. regards, tom lane From gsmith@gregsmith.com Mon May 19 15:47:47 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 33EF02E004B for ; Mon, 19 May 2008 12:47:47 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 76620-01 for ; Mon, 19 May 2008 12:47:41 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from westnet.com (westnet.com [216.187.52.2]) by developer.postgresql.org (Postfix) with ESMTP id 5104A2E0048 for ; Mon, 19 May 2008 12:47:41 -0300 (ADT) Received: from westnet.com (localhost [127.0.0.1]) by westnet.com (8.14.0/8.14.0) with ESMTP id m4JFlckj028926; Mon, 19 May 2008 11:47:38 -0400 (EDT) Received: from localhost (gsmith@localhost) by westnet.com (8.14.0/8.13.2/Submit) with ESMTP id m4JFlc9L028923; Mon, 19 May 2008 11:47:38 -0400 (EDT) X-Authentication-Warning: westnet.com: gsmith owned process doing -bs Date: Mon, 19 May 2008 11:47:38 -0400 (EDT) From: Greg Smith X-X-Sender: gsmith@westnet.com To: Matthew Wakeling cc: pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) In-Reply-To: Message-ID: References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <20080515155232.GC8221@alvh.no-ip.org> <20080516201528.GJ13061@alvh.no-ip.org> <18382.1210992302@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/268 X-Sequence-Number: 30236 On Mon, 19 May 2008, Matthew Wakeling wrote: > Does it really take that long to zero out 8kB of RAM? I thought CPUs were > really quick at doing that! You don't get the whole CPU--you get time slices of one. Some of the cases complaints have come in about have over a thousand connections all fighting for CPU time, and making every one of them block for one guy who needs to fiddle with memory for a while can be a problem. If you're unlucky you won't even be on the same CPU you started on each time you get a little check of time, and you'll run at the speed of RAM rather than that of the CPU--again, fighting for RAM access with every other process on the server. The real question in my mind is why this turns into a bottleneck before the similar task of cleaning the 16MB XLOG segment does. I expected that one would need to be cracked before the CLOG switch time could possibly be an issue, but reports from the field seem to suggest otherwise. -- * Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD From tgl@sss.pgh.pa.us Mon May 19 15:54:05 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 5264E2E0043 for ; Mon, 19 May 2008 12:54:05 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 80750-06 for ; Mon, 19 May 2008 12:53:53 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by developer.postgresql.org (Postfix) with ESMTP id ABC8E2E0032 for ; Mon, 19 May 2008 12:53:53 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m4JFrn6T005900; Mon, 19 May 2008 11:53:49 -0400 (EDT) To: Greg Smith cc: Matthew Wakeling , pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) In-reply-to: References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <20080515155232.GC8221@alvh.no-ip.org> <20080516201528.GJ13061@alvh.no-ip.org> <18382.1210992302@sss.pgh.pa.us> Comments: In-reply-to Greg Smith message dated "Mon, 19 May 2008 11:47:38 -0400" Date: Mon, 19 May 2008 11:53:49 -0400 Message-ID: <5899.1211212429@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/269 X-Sequence-Number: 30237 Greg Smith writes: > The real question in my mind is why this turns into a bottleneck before > the similar task of cleaning the 16MB XLOG segment does. Because we do the latter off-line, or at least try to. regards, tom lane From lists@peufeu.com Mon May 19 17:09:03 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 550492E0043 for ; Mon, 19 May 2008 14:09:03 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 39220-09 for ; Mon, 19 May 2008 14:08:29 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from 30.mail-out.ovh.net (30.mail-out.ovh.net [213.186.62.213]) by developer.postgresql.org (Postfix) with SMTP id 6A5BA2E003B for ; Mon, 19 May 2008 14:08:18 -0300 (ADT) Received: (qmail 14293 invoked by uid 503); 19 May 2008 17:08:37 -0000 Received: from unknown (HELO mail243.ha.ovh.net) (213.186.33.59) by 30.mail-out.ovh.net with SMTP; 19 May 2008 17:08:37 -0000 Received: from b0.ovh.net (HELO queue-out) (213.186.33.50) by b0.ovh.net with SMTP; 19 May 2008 17:08:11 -0000 Received: from par69-8-88-161-102-87.fbx.proxad.net (HELO apollo13.peufeu.com) (88.161.102.87) by ns0.ovh.net with SMTP; 19 May 2008 17:08:11 -0000 Date: Mon, 19 May 2008 19:14:48 +0200 To: "Greg Smith" , "Matthew Wakeling" Subject: Re: I/O on select count(*) From: PFC Cc: pgsql-performance@postgresql.org Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 MIME-Version: 1.0 References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <20080515155232.GC8221@alvh.no-ip.org> <20080516201528.GJ13061@alvh.no-ip.org> <18382.1210992302@sss.pgh.pa.us> Content-Transfer-Encoding: 7bit Message-ID: In-Reply-To: User-Agent: Opera Mail/9.24 (Linux) X-Ovh-Tracer-Id: 12968959553003652708 X-Ovh-Remote: 88.161.102.87 (par69-8-88-161-102-87.fbx.proxad.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-Spam-Check: DONE|H 0.500001/N X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.65 tagged_above=0 required=5 tests=AWL=0.650 X-Spam-Level: X-Archive-Number: 200805/270 X-Sequence-Number: 30238 > The real question in my mind is why this turns into a bottleneck before > the similar task of cleaning the 16MB XLOG segment does. I expected > that one would need to be cracked before the CLOG switch time could > possibly be an issue, but reports from the field seem to suggest > otherwise. Hm, on current CPUs zeroing 8kB of RAM should take less than 2 us... now if it has to be written to disk, that's another story ! From LLonergan@greenplum.com Fri May 23 03:49:05 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 6B32E2E0071 for ; Fri, 23 May 2008 00:49:05 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 65483-08 for ; Fri, 23 May 2008 00:48:31 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from exprod6og102.obsmtp.com (exprod6og102.obsmtp.com [64.18.1.183]) by developer.postgresql.org (Postfix) with SMTP id 7D6202E0041 for ; Fri, 23 May 2008 00:45:06 -0300 (ADT) Received: from source ([63.240.6.3]) (using TLSv1) by exprod6ob102.postini.com ([64.18.5.12]) with SMTP; Thu, 22 May 2008 20:45:04 PDT Received: from d01smtp07.Mi8.com ([172.16.1.114]) by Outbound01.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 22 May 2008 23:12:04 -0400 Received: from MI8NYCMAIL08.Mi8.com ([172.16.1.164]) by d01smtp07.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 22 May 2008 23:12:04 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C8BC82.ACA1D4C6" Subject: Re: I/O on select count(*) Date: Thu, 22 May 2008 23:11:20 -0400 Message-ID: <014F2941B0A1EA47BD61D21526B806E90162C3FD@MI8NYCMAIL08.Mi8.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] I/O on select count(*) Thread-Index: Aci8Jr3A3VPslgXiSsqai3+7DV1E7QAW+6wX From: "Luke Lonergan" To: Cc: , , , X-OriginalArrivalTime: 23 May 2008 03:12:04.0166 (UTC) FILETIME=[C6792E60:01C8BC82] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/312 X-Sequence-Number: 30280 This is a multi-part message in MIME format. ------_=_NextPart_001_01C8BC82.ACA1D4C6 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: base64 SGkgSGFubnUsDQoNCkludGVyZXN0aW5nIHN1Z2dlc3Rpb24gb24gdGhlIHBhcnRpYWwgaW5kZXgh DQoNCkknbGwgZmluZCBvdXQgaWYgd2UgY2FuIGV4dHJhY3Qgb3VyIGNvZGUgdGhhdCBkaWQgdGhl IHdvcmsuICBJdCB3YXMgc2ltcGxlIGJ1dCBzY2F0dGVyZWQgaW4gYSBmZXcgcm91dGluZXMuDQoN CkluIGNvbmNlcHQgaXQgd29ya2VkIGxpa2UgdGhpczoNCg0KMSAtIElnbm9yZSBpZiBoaW50IGJp dHMgYXJlIHVuc2V0LCB1c2UgdGhlbSBpZiBzZXQuICBUaGlzIGFmZmVjdHMgaGVhcGFtIGFuZCB2 YWN1dW0gSSB0aGluay4NCjIgLSBpbXBsZW1lbnQgYSBjYWNoZSBmb3IgY2xvZyBsb29rdXBzIGJh c2VkIG9uIHRoZSBvcHRpbWlzdGljIGFzc3VtcHRpb24gdGh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lKTxCUj4N CnNvIHRoZSBpbmRleCBtYXkgYmUgc21hbGxlcjxCUj4NCjxCUj4NCnN0b3JpbmcgdGhlIGRhdGUg YXMgdHlwZSBhYnN0aW1lIGlzIGFub3RoZXIgd2F5IHRvIHJlZHVjZSBpbmRleCBzaXplLjxCUj4N CjxCUj4NCiZndDsgVHlwaWNhbGx5IHRpbWUtb3JpZW50ZWQgZGF0YSBpcyBuZWFybHkgdGltZSBz b3J0ZWQgYW55d2F5LCBzbyB5b3XigJlsbDxCUj4NCiZndDsgYWxzbyBnZXQgdGhlIGJlbmVmaXQg b2YgYSBjbHVzdGVyZWQgaW5kZXguPEJSPg0KPEJSPg0KLS0tLS0tLS0tLS0tLS0tLTxCUj4NCkhh bm51PEJSPg0KPEJSPg0KPEJSPg0KPC9GT05UPg0KPC9QPg0KDQo8L0JPRFk+DQo8L0hUTUw+ ------_=_NextPart_001_01C8BC82.ACA1D4C6-- From decibel@decibel.org Sat May 24 19:07:21 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 2F3132E003F for ; Sat, 24 May 2008 16:07:21 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 94653-10 for ; Sat, 24 May 2008 16:07:16 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) by developer.postgresql.org (Postfix) with ESMTP id A88E92E002E for ; Sat, 24 May 2008 16:07:17 -0300 (ADT) Received: from [68.241.231.116] (68-241-231-116.area5.spcsdns.net [68.241.231.116]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by noel.decibel.org (Postfix) with ESMTP id C836C56463; Sat, 24 May 2008 14:07:13 -0500 (CDT) In-Reply-To: References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <20080515155232.GC8221@alvh.no-ip.org> <20080516201528.GJ13061@alvh.no-ip.org> <18382.1210992302@sss.pgh.pa.us> Mime-Version: 1.0 (Apple Message framework v753) Content-Type: multipart/signed; micalg=sha1; boundary=Apple-Mail-10--726898619; protocol="application/pkcs7-signature" Message-Id: Cc: pgsql-performance@postgresql.org From: Decibel! Subject: Re: I/O on select count(*) Date: Sat, 24 May 2008 15:06:56 -0400 To: Greg Smith X-Mailer: Apple Mail (2.753) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/327 X-Sequence-Number: 30295 --Apple-Mail-10--726898619 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed On May 18, 2008, at 1:28 AM, Greg Smith wrote: > I just collected all the good internals information included in > this thread and popped it onto http://wiki.postgresql.org/wiki/ > Hint_Bits where I'll continue to hack away at the text until it's > readable. Thanks to everyone who answered my questions here, > that's good progress toward clearing up a very underdocumented area. > > I note a couple of potential TODO items not on the official list > yet that came up during this discussion: > > -Smooth latency spikes when switching commit log pages by > preallocating cleared pages before they are needed > > -Improve bulk loading by setting "frozen" hint bits for tuple > inserts which occur within the same database transaction as the > creation of the table into which they're being inserted > > Did I miss anything? I think everything brought up falls either > into one of those two or the existing "Consider having the > background writer update the transaction status hint bits..." TODO. -Evaluate impact of improved caching of CLOG per Greenplum: Per Luke Longergan: I'll find out if we can extract our code that did the work. It was simple but scattered in a few routines. In concept it worked like this: 1 - Ignore if hint bits are unset, use them if set. This affects heapam and vacuum I think. 2 - implement a cache for clog lookups based on the optimistic assumption that the data was inserted in bulk. Put the cache one call away from heapgetnext() I forget the details of (2). As I recall, if we fall off of the assumption, the penalty for long scans get large-ish (maybe 2X), but since when do people full table scan when they're updates/inserts are so scattered across TIDs? It's an obvious big win for DW work. -- Decibel!, aka Jim C. Nasby, Database Architect decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 --Apple-Mail-10--726898619 Content-Transfer-Encoding: base64 Content-Type: application/pkcs7-signature; name=smime.p7s Content-Disposition: attachment; filename=smime.p7s MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGtTCCAz8w ggKooAMCAQICAQ0wDQYJKoZIhvcNAQEFBQAwgdExCzAJBgNVBAYTAlpBMRUwEwYDVQQIEwxXZXN0 ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEaMBgGA1UEChMRVGhhd3RlIENvbnN1bHRpbmcx KDAmBgNVBAsTH0NlcnRpZmljYXRpb24gU2VydmljZXMgRGl2aXNpb24xJDAiBgNVBAMTG1RoYXd0 ZSBQZXJzb25hbCBGcmVlbWFpbCBDQTErMCkGCSqGSIb3DQEJARYccGVyc29uYWwtZnJlZW1haWxA dGhhd3RlLmNvbTAeFw0wMzA3MTcwMDAwMDBaFw0xMzA3MTYyMzU5NTlaMGIxCzAJBgNVBAYTAlpB MSUwIwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUg UGVyc29uYWwgRnJlZW1haWwgSXNzdWluZyBDQTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA xKY8VXNV+065yplaHmjAdQRwnd/p/6Me7L3N9VvyGna9fww6YfK/Uc4B1OVQCjDXAmNaLIkVcI7d yfArhVqqP3FWy688Cwfn8R+RNiQqE88r1fOCdz0Dviv+uxg+B79AgAJk16emu59l0cUqVIUPSAR/ p7bRPGEEQB5kGXJgt/sCAwEAAaOBlDCBkTASBgNVHRMBAf8ECDAGAQH/AgEAMEMGA1UdHwQ8MDow OKA2oDSGMmh0dHA6Ly9jcmwudGhhd3RlLmNvbS9UaGF3dGVQZXJzb25hbEZyZWVtYWlsQ0EuY3Js MAsGA1UdDwQEAwIBBjApBgNVHREEIjAgpB4wHDEaMBgGA1UEAxMRUHJpdmF0ZUxhYmVsMi0xMzgw DQYJKoZIhvcNAQEFBQADgYE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S6JwtpfTgfKTPuDI6rh7mXWaYYBKGE67P4mEAUGagNYeUcWcdkU4f8HYrEj1wFCNQnlc BjpKkAjmR06TLmHiGncKaWv6UQIm1xwWT/29endaLfs7ZudRo8V9LZApsbLvLb4Tmw1fEmZ60mtR OCoBp2JuGccAzpxGcrJTGO/SdLxez9vaS0qKMdA+ckcH4jGy2bAb8dzeL/jj9MbLzd+X4Sj6Y1MV yY26AEWT4UahT+1PZByjSCgTBilU8Wjt0jWsbN0Pof12HERbyMt9kg4650kgBNW4BgAAAAAAAA== --Apple-Mail-10--726898619-- From decibel@decibel.org Sat May 24 19:15:50 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id E07772E003F for ; Sat, 24 May 2008 16:15:50 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 98722-08 for ; Sat, 24 May 2008 16:15:46 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) by developer.postgresql.org (Postfix) with ESMTP id B5FF72E002E for ; Sat, 24 May 2008 16:15:47 -0300 (ADT) Received: from [68.241.231.116] (68-241-231-116.area5.spcsdns.net [68.241.231.116]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by noel.decibel.org (Postfix) with ESMTP id 398CF56408; Sat, 24 May 2008 14:15:41 -0500 (CDT) In-Reply-To: References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <20080515155232.GC8221@alvh.no-ip.org> <20080516201528.GJ13061@alvh.no-ip.org> <18382.1210992302@sss.pgh.pa.us> Mime-Version: 1.0 (Apple Message framework v753) Content-Type: multipart/signed; micalg=sha1; boundary=Apple-Mail-11--726380586; protocol="application/pkcs7-signature" Message-Id: Cc: pgsql-performance@postgresql.org From: Decibel! Subject: Re: I/O on select count(*) Date: Sat, 24 May 2008 15:15:34 -0400 To: Greg Smith X-Mailer: Apple Mail (2.753) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/328 X-Sequence-Number: 30296 --Apple-Mail-11--726380586 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed On May 18, 2008, at 1:28 AM, Greg Smith wrote: > I just collected all the good internals information included in > this thread and popped it onto http://wiki.postgresql.org/wiki/ > Hint_Bits where I'll continue to hack away at the text until it's > readable. Thanks to everyone who answered my questions here, > that's good progress toward clearing up a very underdocumented area. > > I note a couple of potential TODO items not on the official list > yet that came up during this discussion: > > -Smooth latency spikes when switching commit log pages by > preallocating cleared pages before they are needed > > -Improve bulk loading by setting "frozen" hint bits for tuple > inserts which occur within the same database transaction as the > creation of the table into which they're being inserted > > Did I miss anything? I think everything brought up falls either > into one of those two or the existing "Consider having the > background writer update the transaction status hint bits..." TODO. Blah, sorry for the double-post, but I just remembered a few things... Did we completely kill the idea of the bg_writer *or some other background process* being responsible for setting all hint-bits on dirty pages before they're written out? Also, Simon and Tom had an idea at PGCon: Don't set hint-bits in the back-end if the page isn't already dirty. We'd likely need some heuristics on this... based on Luke's comments about improved CLOG caching maybe we want to set the bits anyway if the tuples without them set are from old transactions (idea being that pulling those CLOG pages would be pretty expensive). Or better yet; if we have to read a CLOG page off disk, set the bits. This could still potentially be a big disadvantage for data warehouses; though perhaps the way to fix that is recommend a backgrounded vacuum after data load. -- Decibel!, aka Jim C. Nasby, Database Architect decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 --Apple-Mail-11--726380586 Content-Transfer-Encoding: base64 Content-Type: application/pkcs7-signature; name=smime.p7s Content-Disposition: attachment; filename=smime.p7s MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGtTCCAz8w ggKooAMCAQICAQ0wDQYJKoZIhvcNAQEFBQAwgd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jLkgLB7490PH6hwYXGg11C5rTrT8aeJI3cMgZISZfL+Je8AW/JIgUnz N9SSf6WL1ABR+iTl34JU00MdzRm3F36vieV78dUTWMSml5/3VGsn1fdeQ2n/jZfTYwAAAAAAAA== --Apple-Mail-11--726380586-- From heikki@enterprisedb.com Mon May 26 13:03:40 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 56F712E0052 for ; Mon, 26 May 2008 10:03:40 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 16582-01 for ; Mon, 26 May 2008 10:03:28 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail01.enterprisedb.com (mail01.enterprisedb.com [63.246.7.168]) by developer.postgresql.org (Postfix) with ESMTP id A36DC2E004D for ; Mon, 26 May 2008 10:03:33 -0300 (ADT) thread-index: Aci/MQBfA9KJgfh5Qi6XV8N9lSuY0Q== Received: from [87.127.95.195] ([87.127.95.195]) by mail01.enterprisedb.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Mon, 26 May 2008 09:04:15 -0400 Message-ID: <483AB515.5050201@enterprisedb.com> Date: Mon, 26 May 2008 14:03:17 +0100 Content-Class: urn:content-classes:message Importance: normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4133 From: "Heikki Linnakangas" Organization: EnterpriseDB User-Agent: Mozilla-Thunderbird 2.0.0.12 (X11/20080420) MIME-Version: 1.0 To: "Decibel!" Cc: "Greg Smith" , Subject: Re: I/O on select count(*) References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <20080515155232.GC8221@alvh.no-ip.org> <20080516201528.GJ13061@alvh.no-ip.org> <18382.1210992302@sss.pgh.pa.us> In-Reply-To: Content-Type: text/plain; format=flowed; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 26 May 2008 13:04:15.0750 (UTC) FILETIME=[002FE260:01C8BF31] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200805/331 X-Sequence-Number: 30299 Decibel! wrote: > Also, Simon and Tom had an idea at PGCon: Don't set hint-bits in the > back-end if the page isn't already dirty. Or even better: set the hint-bits, but don't dirty the page. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com From tgl@sss.pgh.pa.us Mon May 26 15:37:21 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id AB55D2E0032 for ; Mon, 26 May 2008 12:37:21 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 75479-01 for ; Mon, 26 May 2008 12:37:03 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by developer.postgresql.org (Postfix) with ESMTP id C4A042E0052 for ; Mon, 26 May 2008 12:37:03 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m4QFavuV021815; Mon, 26 May 2008 11:36:57 -0400 (EDT) To: "Heikki Linnakangas" cc: "Decibel!" , "Greg Smith" , pgsql-performance@postgresql.org Subject: Re: I/O on select count(*) In-reply-to: <483AB515.5050201@enterprisedb.com> References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <20080515155232.GC8221@alvh.no-ip.org> <20080516201528.GJ13061@alvh.no-ip.org> <18382.1210992302@sss.pgh.pa.us> <483AB515.5050201@enterprisedb.com> Comments: In-reply-to "Heikki Linnakangas" message dated "Mon, 26 May 2008 14:03:17 +0100" Date: Mon, 26 May 2008 11:36:57 -0400 Message-ID: <21814.1211816217@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/335 X-Sequence-Number: 30303 "Heikki Linnakangas" writes: > Decibel! wrote: >> Also, Simon and Tom had an idea at PGCon: Don't set hint-bits in the >> back-end if the page isn't already dirty. > Or even better: set the hint-bits, but don't dirty the page. Which in fact is what Simon suggested, not the other thing. regards, tom lane From simon@2ndquadrant.com Tue May 27 20:52:40 2008 Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id D8B722E0050 for ; Tue, 27 May 2008 17:52:40 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 12186-03 for ; Tue, 27 May 2008 17:52:04 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from outmail136170.authsmtp.com (outmail136170.authsmtp.com [62.13.136.170]) by developer.postgresql.org (Postfix) with ESMTP id 361472E004A for ; Tue, 27 May 2008 17:52:06 -0300 (ADT) Received: from mail-c188.authsmtp.com (mail-c188.authsmtp.com [62.13.128.25]) by punt6.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id m4RKpw0K063186; Tue, 27 May 2008 21:51:58 +0100 (BST) Received: from [192.168.0.3] (85-211-226-243.dyn.gotadsl.co.uk [85.211.226.243]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id m4RKpv0J019312; Tue, 27 May 2008 21:51:57 +0100 (BST) Subject: Re: I/O on select count(*) From: Simon Riggs To: Tom Lane Cc: Heikki Linnakangas , Decibel! , Greg Smith , pgsql-performance@postgresql.org In-Reply-To: <21814.1211816217@sss.pgh.pa.us> References: <920841.71690.qm@web44808.mail.sp1.yahoo.com> <482B1D5F.EE98.0025.0@wicourts.gov> <20080515020553.GN9838@alvh.no-ip.org> <20080515155232.GC8221@alvh.no-ip.org> <20080516201528.GJ13061@alvh.no-ip.org> <18382.1210992302@sss.pgh.pa.us> <483AB515.5050201@enterprisedb.com> <21814.1211816217@sss.pgh.pa.us> Content-Type: text/plain Date: Tue, 27 May 2008 21:54:26 +0100 Message-Id: <1211921666.4489.261.camel@ebony.site> Mime-Version: 1.0 X-Mailer: Evolution 2.12.0 Content-Transfer-Encoding: 7bit X-Server-Quench: bf10485f-2c2e-11dd-aecc-001871e930f4 X-AuthRoute: OCdxZQATClZOTQEd DAteCiNZVAwpPBRK HVkIKg5MJUcNSQVJ NksacxtFagJbYFhI HGQLW1xEUlx7XGJ/ bg0fZQBDYEtPQQdo VlZLRlFNFgBqBAMB SEMaMGIyMQU8eH95 ZkdgEHFdXE00JxB8 QkpcEDsbZzRiPX0e URQMalIBI1BXfh9E Yld+AXoOYTMDKBg1 TUcABx0LExJlDREd Y0YqZVUUCV0GGjM3 W1gJGigpAQ1HBk0g X-Authentic-SMTP: 61633235383639.cat.dmpriest.net.uk:1045/Kp X-Report-SPAM: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-Virus-Status: No virus detected - but ensure you scan with your own anti-virus system! X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/349 X-Sequence-Number: 30317 On Mon, 2008-05-26 at 11:36 -0400, Tom Lane wrote: > "Heikki Linnakangas" writes: > > Decibel! wrote: > >> Also, Simon and Tom had an idea at PGCon: Don't set hint-bits in the > >> back-end if the page isn't already dirty. > > > Or even better: set the hint-bits, but don't dirty the page. > > Which in fact is what Simon suggested, not the other thing. Just raised this on -hackers, BTW. -- Simon Riggs www.2ndQuadrant.com PostgreSQL Training, Services and Support