I have done the following test pn v9.2.4 with two concurrent sessions:
-- session no.1
tmp1=# create table t1 ( t text );
CREATE TABLE
Tempo: 37,351 ms
tmp1=# create table t2 ( t text );
CREATE TABLE
Tempo: 33,363 ms
tmp1=# create or replace function f1( out tx text )
tmp1-# language plpgsql
tmp1-
On Fri, Jul 12, 2013 at 9:24 AM, Kevin Grittner wrote:
> Vincenzo Romano wrote:
>
>> I'd like to "replace" a full table F with an empty one E.
>> In order to do this I see only one way:
>>
>> ALTER TABLE F RENAME TO T;
>> ALTER TABLE E RENAME TO F;
>> ALTER TABLE T RENAME TO E; -- optional
>>
>>
Vincenzo Romano wrote:
> Would you please elaborate more on the "wait[ing] long enough
> after the COMMIT" ?
You can note the time when you commit the transaction, and then
poll pg_stat_activity until there are no active transactions which
started before that.
You can sometimes simplify this a
> Vincenzo Romano wrote:
>
>> I'd like to "replace" a full table F with an empty one E.
>> In order to do this I see only one way:
>>
>> ALTER TABLE F RENAME TO T;
>> ALTER TABLE E RENAME TO F;
>> ALTER TABLE T RENAME TO E; -- optional
>>
>> This implies there's a moment when the full table doesn'
Vincenzo Romano wrote:
> I'd like to "replace" a full table F with an empty one E.
> In order to do this I see only one way:
>
> ALTER TABLE F RENAME TO T;
> ALTER TABLE E RENAME TO F;
> ALTER TABLE T RENAME TO E; -- optional
>
> This implies there's a moment when the full table doesn't exist.
>