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

Re: Temporary tables under hot standby

From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Temporary tables under hot standby
Date: 2012-05-03 09:11:56
Message-ID: CA+U5nMLXqVNcOHbXDd0h0ODxMMPNAk42NF8Wa6R-o6s5ZZOEqQ@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
On Thu, May 3, 2012 at 1:57 AM, Josh Berkus <josh(at)agliodbs(dot)com> wrote:
> Michael,
>
>> What is the use case for temporary tables on a hot standby server?
>>
>> Perhaps this is a noobie question, but it seems to me that a hot standby
>> server's use by* applications* or *users* should be limited to transactions
>> that don't alter the database in any form.
>
> A very common use for asynchronous replicas is to offload long-running
> reporting jobs onto the replica so that they don't bog down the master.
>  However, long-running reporting jobs often require temporary tables,
> especially if they use some 3rd-party vendor's reporting tool.  For
> example, the average Microstrategy report involves between 1 and 12
> temporary tables.

Many tools and applications choose to use temporary tables. Often this
isn't necessary at all, for example in MicroStrategy it is possible to
ask it to use derived tables instead and thus avoid using temp tables,
so that can still work against Hot Standby.

Derived tables means rewriting the query from
CREATE TEMP TABLE s1 AS <SELECT1>;
SELECT ... FROM s1 WHERE ...

into
SELECT ... FROM (<SELECT1>) AS s1 WHERE

Many apps are easily rewritten in this way and so the lack of temp
tables isn't a total blocker in the way some people think.

If we had Global Temp Tables, users would still need to rewrite their
code, just in a different way, like this...
(on master)
CREATE GLOBAL TEMP TABLE s1 (....);

(on standby)
INSERT INTO s1 <SELECT1>;
SELECT ... FROM s1 WHERE ...
which seems to me to be actually harder than just rewriting as derived
table and isn't an option on Microstrategy etc, hence my observation
that GTTs don't help HS much. What I would like to see, one day, is
for temp tables to work without any changes.

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

In response to

Responses

pgsql-hackers by date

Next:From: Simon RiggsDate: 2012-05-03 09:23:31
Subject: Re: Modeling consumed shmem sizes, and some thorns
Previous:From: Jan UrbańskiDate: 2012-05-03 09:04:38
Subject: Re: PL/Python result set slicing broken in Python 3

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