Re: [GENERAL] Means to emulate global temporary table

Поиск
Список
Период
Сортировка
От Steve Atkins
Тема Re: [GENERAL] Means to emulate global temporary table
Дата
Msg-id E153C0AA-A9BB-4097-B45E-2EC90B979A9B@blighty.com
обсуждение исходный текст
Ответ на Re: [GENERAL] Means to emulate global temporary table  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-general
> On Jan 11, 2017, at 7:02 PM, David G. Johnston <david.g.johnston@gmail.com> wrote:
>
> ​"throughout" mustn't mean "by other sessions" or this becomes unwieldy.
>
> Here's a mock-up:
>
> CREATE TABLE template_table ();
> CREATE VIEW view_over_my_template_instance AS SELECT * FROM my_instance_of_template_table; --fails if done here
withoutthe desired feature 
>
> In a given session:
>
> CREATE TEMP TABLE my_instance_of_template_table LIKE template_table;
> SELECT * FROM view_over_my_template_table; -- returns only this session's temp table data
>
> Other sessions can simultaneously execute the same SELECT * FROM view_over_* and get their own results.
>
> The goal is to avoid having to CREATE TEMP TABLE within the session but instead be able to do:
>
> CREATE GLOBAL TEMP TABLE my_instance_of_template_table LIKE template_table;
>
> And have the CREATE VIEW not fail and the session behavior as described.

Would this differ in any user-visible way from what you'd have if you executed at the start of each session:

CREATE TEMPORARY TABLE my_instance_of_template_table LIKE template_table;
CREATE TEMPORARY VIEW view_over_my_template_instance AS SELECT * FROM my_instance_of_template_table;

There'd be a small amount of session startup overhead, but that could be handled at the pooler level and amortized down
tozero. 

Cheers,
  Steve



В списке pgsql-general по дате отправления:

Предыдущее
От: Ian Lewis
Дата:
Сообщение: Re: [GENERAL] Means to emulate global temporary table
Следующее
От: Andreas Joseph Krogh
Дата:
Сообщение: Re: [GENERAL] Question slow query