Re: Cache relation sizes? - Mailing list pgsql-hackers

From Thomas Munro
Subject Re: Cache relation sizes?
Date
Msg-id CA+hUKG+=hy51hBJqVQPwug3U8nhw3Fb3v7Dq9=Nr0eZUAu1Dqg@mail.gmail.com
Whole thread Raw
In response to Re: Cache relation sizes?  (Amit Kapila <amit.kapila16@gmail.com>)
Responses Re: Cache relation sizes?  (Andy Fan <zhihui.fan1213@gmail.com>)
回复:Re: Cache relation sizes?  ("陈佳昕(步真)" <buzhen.cjx@alibaba-inc.com>)
Re: Cache relation sizes?  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
On Tue, Nov 17, 2020 at 10:48 PM Amit Kapila <amit.kapila16@gmail.com> wrote:
> Yeah, it is good to verify VACUUM stuff but I have another question
> here. What about queries having functions that access the same
> relation (SELECT c1 FROM t1 WHERE c1 <= func(); assuming here function
> access the relation t1)? Now, here I think because the relation 't1'
> is already opened, it might use the same value of blocks from the
> shared cache even though the snapshot for relation 't1' when accessed
> from func() might be different. Am, I missing something, or is it
> dealt in some way?

I think it should be covered by the theory about implicit memory
barriers snapshots, but to simplify things I have now removed the
lock-free stuff from the main patch (0001), because it was a case of
premature optimisation and it distracted from the main concept.  The
main patch has 128-way partitioned LWLocks for the mapping table, and
then per-relfilenode spinlocks for modifying the size.  There are
still concurrency considerations, which I think are probably handled
with the dirty-update-wins algorithm you see in the patch.  In short:
due to extension and exclusive locks, size changes AKA dirty updates
are serialised, but clean updates can run concurrently, so we just
have to make sure that clean updates never clobber dirty updates -- do
you think that is on the right path?

Attachment

pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: pl/pgsql feature request: shorthand for argument and local variable references
Next
From: Greg Stark
Date:
Subject: Re: don't allocate HashAgg hash tables when running explain only