Shared invalidation cache messages for temporary tables

Lists: pgsql-hackers
From: Bruce Momjian <bruce(at)momjian(dot)us>
To: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Shared invalidation cache messages for temporary tables
Date: 2011-03-12 01:44:57
Message-ID: 201103120144.p2C1ivt01735@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Looking at the code, it seems we create shared invalidation messages for
temporary table activity? Is this true? Should we be avoiding it?

I tested this by reviewing the code and checking calls to
CacheInvalidateHeapTuple(), which happens for temporary table
creation/destruction.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: Shared invalidation cache messages for temporary tables
Date: 2011-03-14 08:34:20
Message-ID: 1300091660.1790.7644.camel@ebony
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, 2011-03-11 at 20:44 -0500, Bruce Momjian wrote:
> Looking at the code, it seems we create shared invalidation messages for
> temporary table activity? Is this true? Should we be avoiding it?
>
> I tested this by reviewing the code and checking calls to
> CacheInvalidateHeapTuple(), which happens for temporary table
> creation/destruction.

Yes, that gets called.

But in PrepareForTupleInvalidation() we ignore everything apart from
system relations, as the first check.

--
Simon Riggs http://www.2ndQuadrant.com/books/
PostgreSQL Development, 24x7 Support, Training and Services


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: Shared invalidation cache messages for temporary tables
Date: 2011-03-14 12:42:09
Message-ID: 201103141242.p2ECg9J26347@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Simon Riggs wrote:
> On Fri, 2011-03-11 at 20:44 -0500, Bruce Momjian wrote:
> > Looking at the code, it seems we create shared invalidation messages for
> > temporary table activity? Is this true? Should we be avoiding it?
> >
> > I tested this by reviewing the code and checking calls to
> > CacheInvalidateHeapTuple(), which happens for temporary table
> > creation/destruction.
>
> Yes, that gets called.
>
> But in PrepareForTupleInvalidation() we ignore everything apart from
> system relations, as the first check.

OK, so this is no problem? There is no optimization needed here?
Thanks.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Shared invalidation cache messages for temporary tables
Date: 2011-03-14 13:33:19
Message-ID: AANLkTim8JuSqoUwgcLgeqp0uf7x4nTGE0C2A7RmnDwHP@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Mar 14, 2011 at 8:42 AM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> Simon Riggs wrote:
>> On Fri, 2011-03-11 at 20:44 -0500, Bruce Momjian wrote:
>> > Looking at the code, it seems we create shared invalidation messages for
>> > temporary table activity?  Is this true?  Should we be avoiding it?
>> >
>> > I tested this by reviewing the code and checking calls to
>> > CacheInvalidateHeapTuple(), which happens for temporary table
>> > creation/destruction.
>>
>> Yes, that gets called.
>>
>> But in PrepareForTupleInvalidation() we ignore everything apart from
>> system relations, as the first check.
>
> OK, so this is no problem?  There is no optimization needed here?
> Thanks.

Since your original email is fairly unclear about what you think the
problem is, it's a bit hard to speculate here, but like Simon, I don't
see any obvious problem here. Maybe you're asking not so much about
inserts, updates, or deletes into temporary tables but about creating
and making modifications to them, which will generate catcache and
relcache flushes when the pg_class/pg_attribute entries are updated.
But I don't think those invalidation messages can be optimized away,
since other backends can access temporary tables of other sessions in
limited ways - for example, they can drop them.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Shared invalidation cache messages for temporary tables
Date: 2011-03-14 14:21:41
Message-ID: 201103141421.p2EELf511970@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Robert Haas wrote:
> On Mon, Mar 14, 2011 at 8:42 AM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> > Simon Riggs wrote:
> >> On Fri, 2011-03-11 at 20:44 -0500, Bruce Momjian wrote:
> >> > Looking at the code, it seems we create shared invalidation messages for
> >> > temporary table activity? ?Is this true? ?Should we be avoiding it?
> >> >
> >> > I tested this by reviewing the code and checking calls to
> >> > CacheInvalidateHeapTuple(), which happens for temporary table
> >> > creation/destruction.
> >>
> >> Yes, that gets called.
> >>
> >> But in PrepareForTupleInvalidation() we ignore everything apart from
> >> system relations, as the first check.
> >
> > OK, so this is no problem? ?There is no optimization needed here?
> > Thanks.
>
> Since your original email is fairly unclear about what you think the
> problem is, it's a bit hard to speculate here, but like Simon, I don't
> see any obvious problem here. Maybe you're asking not so much about
> inserts, updates, or deletes into temporary tables but about creating
> and making modifications to them, which will generate catcache and
> relcache flushes when the pg_class/pg_attribute entries are updated.
> But I don't think those invalidation messages can be optimized away,
> since other backends can access temporary tables of other sessions in
> limited ways - for example, they can drop them.

Sorry, yes that was my point --- should we be doing as much cache
invalidation traffic for temporary tables as we are doing? I think you
are saying we are fine and there are no optimizations possible.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Shared invalidation cache messages for temporary tables
Date: 2011-03-14 14:29:29
Message-ID: AANLkTi=D7OQ-S1bYrJkTu+y4JR3o_2PV8R+EbFqriQXa@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Mar 14, 2011 at 10:21 AM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
>> Since your original email is fairly unclear about what you think the
>> problem is, it's a bit hard to speculate here, but like Simon, I don't
>> see any obvious problem here.  Maybe you're asking not so much about
>> inserts, updates, or deletes into temporary tables but about creating
>> and making modifications to them, which will generate catcache and
>> relcache flushes when the pg_class/pg_attribute entries are updated.
>> But I don't think those invalidation messages can be optimized away,
>> since other backends can access temporary tables of other sessions in
>> limited ways - for example, they can drop them.
>
> Sorry, yes that was my point --- should we be doing as much cache
> invalidation traffic for temporary tables as we are doing?  I think you
> are saying we are fine and there are no optimizations possible.

Yeah, I think so. I mean, if you have a concrete example of this
causing a problem, then we can look into it, but my intuition is that
it's OK. Programmers intuition are notoriously wrong, of course, so
we're all just shooting in the dark until we have something to
measure.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Jim Nasby <jim(at)nasby(dot)net>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, Simon Riggs <simon(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Shared invalidation cache messages for temporary tables
Date: 2011-03-16 22:05:06
Message-ID: 17A814D1-3355-4B98-AFD6-C1D4EBAE235C@nasby.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mar 14, 2011, at 9:29 AM, Robert Haas wrote:

> On Mon, Mar 14, 2011 at 10:21 AM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
>>> Since your original email is fairly unclear about what you think the
>>> problem is, it's a bit hard to speculate here, but like Simon, I don't
>>> see any obvious problem here. Maybe you're asking not so much about
>>> inserts, updates, or deletes into temporary tables but about creating
>>> and making modifications to them, which will generate catcache and
>>> relcache flushes when the pg_class/pg_attribute entries are updated.
>>> But I don't think those invalidation messages can be optimized away,
>>> since other backends can access temporary tables of other sessions in
>>> limited ways - for example, they can drop them.
>>
>> Sorry, yes that was my point --- should we be doing as much cache
>> invalidation traffic for temporary tables as we are doing? I think you
>> are saying we are fine and there are no optimizations possible.
>
> Yeah, I think so. I mean, if you have a concrete example of this
> causing a problem, then we can look into it, but my intuition is that
> it's OK. Programmers intuition are notoriously wrong, of course, so
> we're all just shooting in the dark until we have something to
> measure.

Sounds like there should be a comment somewhere in the code that explains why we actually need those messages...
--
Jim C. Nasby, Database Architect jim(at)nasby(dot)net
512.569.9461 (cell) http://jim.nasby.net


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Jim Nasby <jim(at)nasby(dot)net>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Shared invalidation cache messages for temporary tables
Date: 2011-09-06 02:08:22
Message-ID: 201109060208.p8628Ni21667@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Jim Nasby wrote:
> On Mar 14, 2011, at 9:29 AM, Robert Haas wrote:
>
> > On Mon, Mar 14, 2011 at 10:21 AM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> >>> Since your original email is fairly unclear about what you think the
> >>> problem is, it's a bit hard to speculate here, but like Simon, I don't
> >>> see any obvious problem here. Maybe you're asking not so much about
> >>> inserts, updates, or deletes into temporary tables but about creating
> >>> and making modifications to them, which will generate catcache and
> >>> relcache flushes when the pg_class/pg_attribute entries are updated.
> >>> But I don't think those invalidation messages can be optimized away,
> >>> since other backends can access temporary tables of other sessions in
> >>> limited ways - for example, they can drop them.
> >>
> >> Sorry, yes that was my point --- should we be doing as much cache
> >> invalidation traffic for temporary tables as we are doing? I think you
> >> are saying we are fine and there are no optimizations possible.
> >
> > Yeah, I think so. I mean, if you have a concrete example of this
> > causing a problem, then we can look into it, but my intuition is that
> > it's OK. Programmers intuition are notoriously wrong, of course, so
> > we're all just shooting in the dark until we have something to
> > measure.
>
> Sounds like there should be a comment somewhere in the code that
> explains why we actually need those messages...

Done.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +