public inbox for [email protected]  
help / color / mirror / Atom feed
From: Konstantin Knizhnik <[email protected]>
To: Pavel Stehule <[email protected]>
Cc: Craig Ringer <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: Global temporary tables
Date: Mon, 23 Sep 2019 10:57:08 +0300
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAFj8pRDNrK9wAWC+bJ71PYz4CA59qZ_DzPFCihca=E2Vrx6ifA@mail.gmail.com>
References: <[email protected]>
	<CAFj8pRDfDGReVdPcD_nXqnukMfY2gmi1mjkB3o1-KQgQz17mwA@mail.gmail.com>
	<[email protected]>
	<CAFj8pRBEVp-wp-EAbuHaTuefc1WPg897iBW_1r5-wZ2NKKkNOw@mail.gmail.com>
	<[email protected]>
	<[email protected]>
	<CAFj8pRCScMe34apHZz7HL6tmzkVwBba_HbcqTBJAv9n=oq1ADA@mail.gmail.com>
	<[email protected]>
	<CAFj8pRAFbHvdOTyOjB2utcBQDojXBr+Uuw+yWRCsz9Rv7GYJhg@mail.gmail.com>
	<[email protected]>
	<CAFj8pRB5PPsNRCuihUvU192jDs1=Tb5khynoR73x69Rhupqe7Q@mail.gmail.com>
	<[email protected]>
	<CAFj8pRCMmU7XPYpfA7FZS4pFBPwHZ=+B6wF6Z72LTXHEzfkDFA@mail.gmail.com>
	<[email protected]>
	<[email protected]>
	<CAFj8pRDNrK9wAWC+bJ71PYz4CA59qZ_DzPFCihca=E2Vrx6ifA@mail.gmail.com>



On 20.09.2019 19:43, Pavel Stehule wrote:
>
>     1. I do not need them at all.
>     2. Eliminate catalog bloating.
>     3. Mostly needed for compatibility with Oracle (simplify porting,...).
>     4. Parallel query execution.
>     5. Can be used at replica.
>     6. More efficient use of resources (first of all memory).
>
>
> There can be other point important for cloud. Inside some cloud 
> usually there are two types of discs - persistent (slow) and ephemeral 
> (fast). We effectively used temp tables there because we moved temp 
> tablespace to ephemeral discs.

Yes, I already heard this argument and agree with it.
I just want to notice two things:
1. My assumption is that in most cases data of temporary table can fit 
in memory (certainly if we are not limiting them by temp_buffers = 8MB, 
but store in shared buffers) and so there is on need to write them to 
the persistent media at all.
2. Global temp tables do not substitute local temp tables, accessed 
through local buffers. So if you want to use temporary storage, you will 
always have a way to do it.
The question is whether we need to support two kinds of global temp 
tables (with shared or private buffers) or just implement one of them.

>
> I missing one point in your list - developer's comfort - using temp 
> tables is just much more comfortable - you don't need create it again, 
> again, .. Due this behave is possible to reduce @2 and @3 can be nice 
> side effect. If you reduceĀ @2 to zero, then @5 should be possible 
> without any other.
>
Sorry, I do not completely understand your point here
You can use normal (permanent) table and you will not have to create 
them again and again. It is also possible to use them for storing 
temporary data - just need to truncate table when data is not needed any 
more.
Certainly you can not use the same table in more than one backend. Here 
is the main advantage of temp tables - you can have storage of 
per-session data and do not worry about possible name conflicts.

 From the other side: there are many cases where format of temporary 
data is not statically known: it is determined dynamically during 
program execution.
In this case local temp table provides the most convenient mechanism for 
working with such data.

This is why I think that ewe need to have both local and global temp tables.

Also I do not agree with your statement "If you reduceĀ @2 to zero, then 
@5 should be possible without any other".
In the solution implemented by Aleksander Alekseev metadata of temporary 
tables is kept in memory and not affecting catalog at all.
But them still can not be used at replica.
There are still some serious problems which need to be fixed to able it:
allow insert/update/delete statements for read-only transactions, 
somehow assign XIDs for them, implement savepoints and rollback of such 
transactions.
All this was done in the last version of my patch.
Yes, it doesn't depend on whether we are using shared or private buffers 
for temporary tables. The same approach can be implemented for both of them.
The question is whether we are really need temp tables at replica and if 
so, do we need full transaction support for them, including rollbacks, 
subtransactions.

-- 
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company



view thread (492+ messages)  latest in thread

reply

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Global temporary tables
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox