Skip site navigation (1) Skip section navigation (2)

Re: idea: global temp tables

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Greg Stark" <stark(at)enterprisedb(dot)com>
Cc: "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>,"Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>,"PostgreSQL Hackers" <pgsql-hackers(at)postgresql(dot)org>,"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: idea: global temp tables
Date: 2009-04-29 20:08:16
Message-ID: 49F86D60.EE98.0025.0@wicourts.gov (view raw or flat)
Thread:
Lists: pgsql-hackers
Greg Stark <stark(at)enterprisedb(dot)com> wrote: 
> On Wed, Apr 29, 2009 at 7:57 PM, Kevin Grittner
> <Kevin(dot)Grittner(at)wicourts(dot)gov> wrote:
>> But the scaling issues are there already with temp tables.  This
>> actually makes it better, not worse, because the table can be
>> materialized once per session, not once per request.
> 
> Currently you have to issue CREATE TABLE and associated DDL
> manually.  That makes it clear to the user that they're executing
> DDL and should expect it to behave like DDL.
> 
> I don't understand what you mean by a cost once per request. You
> only have to create the temporary table on the first request. If you
> can't tell which is the first request you only have to test whether
> it exists which doesn't incur the consequences that ddl incurs.
 
True.  I got myself thinking that without this feature people would be
dropping the table after each use, which doesn't have to be the case.
 
> What we're talking about means that when someone issues "SELECT *
> FROM cache" they're going to -- unexpected -- be a) turning their
> virtual transaction id into a real transaction id b) creating a new
> entry in pg_catalog and its indexes c) wal logging the new
> pg_catalog entry (including having to fsync at commit time) d)
> acquiring an exclusive lock on the new entry.
 
Only if they are making the first reference to the table in that
session, and it's only unexpected if they don't know that such a
reference to a global temp table can cause the table to materialize. 
Surely you will grant that someone referencing such a table should
know what it is?
 
> There have been posts by people who were bitten by expecting that
> they could create temporary work tables for short frequently run
> queries who didn't realize that would mean pg_class would have to be
> vacuumed every few minutes and that it would slow down every index
> lookup for table names.
 
Like I said, I have run into performance problems with temp table
creation, especially when write barriers were configured on due to
battery failure or OS misconfiguration, and the cost turned out to be
almost entirely in the creation of the disk files which support the
temp table -- base, toast, indexes, etc.  Unless you can fix the big
problems, worrying about the stuff we do optimize well will be a drop
in the bucket.
 
> I don't see it as friendly to make that the implicit
> behaviour for innocent looking dml operations.
 
Perhaps a note in the documentation of global temporary tables could
set appropriate expectations?  It seems that your whole objection to
adding the requested feature hinges on anticipation of particular user
expectations.
 
-Kevin

In response to

pgsql-hackers by date

Next:From: Greg StarkDate: 2009-04-29 20:39:03
Subject: Re: idea: global temp tables
Previous:From: Alvaro HerreraDate: 2009-04-29 20:07:11
Subject: Re: idea: global temp tables

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group