From: lars hofhansl <lhofhansl@yahoo.com>
To: Pavan Deolasee <pavan.deolasee@gmail.com>
To: Merlin Moncure <mmoncure@gmail.com>
Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>
Cc: Ivan Voras <ivoras@freebsd.org>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: UPDATEDs slowing SELECTs in a fully cached database
Date: Fri, 29 Jul 2011 08:57:37 -0700 (PDT)
Message-ID: <1311955057.37123.YahooMailNeo@web121713.mail.ne1.yahoo.com> (raw)
In-Reply-To: <CABOikdPXPfY8C46YBnb0CbBJ80af4FOfD47KEJzS-=EyHA=u-Q@mail.gmail.com>
References: <4E16479D.3050605@yahoo.com>
<4E1A0CBC.6090009@yahoo.com>
<4E1A31AB.9010201@postnewspapers.com.au>
<1310359653.80687.YahooMailRC@web121705.mail.ne1.yahoo.com>
<4E1AEDAB020000250003F1C3@gw.wicourts.gov>
<4E1B41EA.90104@yahoo.com>
<4E1B05CC020000250003F1E6@gw.wicourts.gov>
<CAHyXU0wPhZsQ_pMzfUWW0O=t_+2uwF-CJQNw-nuaxkjbi2zPEQ@mail.gmail.com>
<4E1B810D.4070404@yahoo.com>
<4E1B90AF.1020408@yahoo.com>
<ivho9v$6dp$1@dough.gmane.org>
<4E1C9A05.7060005@yahoo.com>
<4E1C5563020000250003F252@gw.wicourts.gov>
<CAHyXU0zFwKcVPU23HJDxmuf+W-c_HzoROwGN11suyTeSvGVRaw@mail.gmail.com>
<4E1CD580.3030100@yahoo.com>
<CAHyXU0x0npSoSSDEJ26sktAn9=1Apv6RtphSSHsvNpYjCE5-Tg@mail.gmail.com>
<CABOikdPXPfY8C46YBnb0CbBJ80af4FOfD47KEJzS-=EyHA=u-Q@mail.gmail.com>
Thanks Pavan!
I think the most important points are still that:
1. The WAL write should be happening asynchronously (if that is possible)
2. There should be an option do not perform these compactions if the page is only touched by reads.
(Assuming that when most of the databaseresides in the cache these optimizations are less important.)
-- Lars
----- Original Message -----
From: Pavan Deolasee <pavan.deolasee@gmail.com>
To: Merlin Moncure <mmoncure@gmail.com>
Cc: lars <lhofhansl@yahoo.com>; Kevin Grittner <Kevin.Grittner@wicourts.gov>; Ivan Voras <ivoras@freebsd.org>; pgsql-performance@postgresql.org
Sent: Wednesday, July 27, 2011 7:15 AM
Subject: Re: [PERFORM] UPDATEDs slowing SELECTs in a fully cached database
On Wed, Jul 13, 2011 at 10:52 AM, Merlin Moncure <mmoncure@gmail.com> wrote:
...
There are couple of other (very important) things that HOT does, but
probably its not advertised a lot. Even for non-HOT updates (which
means either indexed columns were changed or page ran out of free
space) or deletes, HOT prunes those tuples and instead mark the line
pointer as DEAD. The page is defragmented and dead space is recovered.
Each such dead tuple now only consumes two bytes in the page until
vacuum removes the dead line pointers. Thats the reason why OP is
seeing the behavior even when index columns are being updated.
We made a few adjustments to ensure that a page is not pruned too
early. So we track the oldest XID that did any updates/deletes to the
page and attempt pruning only when the RecentXmin is past the XID. We
also mark the page as "full" if some previous update did not find
enough free space to do in-block update and use that hint to decide if
we should attempt to prune the page. Finally, we prune only if we get
the cleanup lock without blocking.
What might be worth looking at this condition in pruneheap.c:
/*
* We prune when a previous UPDATE failed to find enough space on the page
* for a new tuple version, or when free space falls below the relation's
* fill-factor target (but not less than 10%).
*
* Checking free space here is questionable since we aren't holding any
* lock on the buffer; in the worst case we could get a bogus answer. It's
* unlikely to be *seriously* wrong, though, since reading either pd_lower
* or pd_upper is probably atomic. Avoiding taking a lock seems more
* important than sometimes getting a wrong answer in what is after all
* just a heuristic estimate.
*/
minfree = RelationGetTargetPageFreeSpace(relation,
HEAP_DEFAULT_FILLFACTOR);
minfree = Max(minfree, BLCKSZ / 10);
if (PageIsFull(page) || PageGetHeapFreeSpace(page) < minfree)
{
So if the free space in a page falls below the fill-factor or 10% of
the block size, we would try to prune the page. We probably need to
revisit this area and see if we need to tune HOT ever better. One
option could be to see how much space we are going to free and carry
out the operation only if its significant enough to justify the cost.
I know we had done several benchmarking tests while HOT development,
but the tuning mechanism still may not be perfect for all kinds of
work loads and it would probably never be.
Thanks,
Pavan
--
Pavan Deolasee
EnterpriseDB http://www.enterprisedb.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: lhofhansl@yahoo.com, pavan.deolasee@gmail.com, mmoncure@gmail.com, Kevin.Grittner@wicourts.gov, ivoras@freebsd.org
Subject: Re: UPDATEDs slowing SELECTs in a fully cached database
In-Reply-To: <1311955057.37123.YahooMailNeo@web121713.mail.ne1.yahoo.com>
References: <4E16479D.3050605@yahoo.com> <4E1A0CBC.6090009@yahoo.com> <4E1A31AB.9010201@postnewspapers.com.au> <1310359653.80687.YahooMailRC@web121705.mail.ne1.yahoo.com> <4E1AEDAB020000250003F1C3@gw.wicourts.gov> <4E1B41EA.90104@yahoo.com> <4E1B05CC020000250003F1E6@gw.wicourts.gov> <CAHyXU0wPhZsQ_pMzfUWW0O=t_+2uwF-CJQNw-nuaxkjbi2zPEQ@mail.gmail.com> <4E1B810D.4070404@yahoo.com> <4E1B90AF.1020408@yahoo.com> <ivho9v$6dp$1@dough.gmane.org> <4E1C9A05.7060005@yahoo.com> <4E1C5563020000250003F252@gw.wicourts.gov> <CAHyXU0zFwKcVPU23HJDxmuf+W-c_HzoROwGN11suyTeSvGVRaw@mail.gmail.com> <4E1CD580.3030100@yahoo.com> <CAHyXU0x0npSoSSDEJ26sktAn9=1Apv6RtphSSHsvNpYjCE5-Tg@mail.gmail.com> <CABOikdPXPfY8C46YBnb0CbBJ80af4FOfD47KEJzS-=EyHA=u-Q@mail.gmail.com> <1311955057.37123.YahooMailNeo@web121713.mail.ne1.yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox