Re: Proposal: COUNT(*) (and related) speedup

From: Joshua Yanovski <pythonesque(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Proposal: COUNT(*) (and related) speedup
Date: 2014-04-04 21:51:06
Message-ID: CABz-M-GziviSU7igp43D4QaQZ+P4Sse43VZ8d5p8Bo_wyKrJ+A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Yeah, you're right, I believe that every code path in VACUUM that
leads to the visibility map bit being set also leads to all remaining
tuples on the page being frozen. So in a world without heap pruning,
frozen should be a reliable proxy for "value of the tuple the last
time it was added to the counter". If you count -1 for a frozen
tuple, and 1 for a visible tuple, you should end up at precisely the
delta from the last time the page was turned visible.

It seems to me that with this definition of delta, the concurrent
COUNT(*) case is fine. The counter isn't affected by the dirtying of
the page, nor is the delta for the page. The result will be
completely consistent with what it would have been had the page dirty
never happened. But concurrent VACUUM under this definition fails. So
yeah, I'll drop this until I have a concrete idea of how (or if) to
proceed. Thanks for the feedback.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2014-04-04 22:13:40 Idea for aggregates
Previous Message Tom Lane 2014-04-04 21:31:56 Re: Another thought about search_path semantics