Re: Rewrite, normal execution vs. EXPLAIN ANALYZE

Поиск
Список
Период
Сортировка
От Marko Tiikkaja
Тема Re: Rewrite, normal execution vs. EXPLAIN ANALYZE
Дата
Msg-id 4C49EB59.9090308@cs.helsinki.fi
обсуждение исходный текст
Ответ на Re: Rewrite, normal execution vs. EXPLAIN ANALYZE  (Marko Tiikkaja <marko.tiikkaja@cs.helsinki.fi>)
Ответы Re: Rewrite, normal execution vs. EXPLAIN ANALYZE  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
On 7/23/2010 10:06 PM, I wrote:
> ProcessQuery() and ExplainOnePlan().  ProcessQuery calls
> PushActiveSnapshot(GetTransactionSnapshot()) for every statement while
> ExplainOnePlan calls PushUpdatedSnapshot(GetActiveSnapshot()).

Here's a test case demonstrating the difference:

=# create table foo(a int);
CREATE TABLE
=# create table bar(a int);
CREATE TABLE
=# create table baz(a int);
CREATE TABLE

=# create rule foorule as on update to foo do instead (select 
pg_sleep(5); insert into bar select * from baz);
CREATE RULE

=# insert into foo values(0);


no EXPLAIN:

=# truncate bar, baz;
TRUNCATE TABLE

T1=# begin; update foo set a=a;
BEGIN
-- sleeps..

T2=# insert into baz values(0);
INSERT 0 1

-- T1 returns pg_sleep
----------

(1 row)

UPDATE 0

T1=# select * from bar; a
--- 0
(1 row)



EXPLAIN:

=# truncate bar, baz;
TRUNCATE TABLE

T1=# begin; explain analyze update foo set a=a;
BEGIN
-- sleeps..

T2=# insert into baz values(0);
INSERT 0 1

-- T1 returns
(QUERY PLAN)

T1=# select * from bar; a
---
(0 rows)


This may be a bit hard to follow, but essentially what happens is that 
in EXPLAIN ANALYZE, the INSERT in the rule does not see the changes made 
by T2 to baz while in the regular execution scenario it does.


Regards,
Marko Tiikkaja


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

Предыдущее
От: Robert Haas
Дата:
Сообщение: reminder... beta4 is coming
Следующее
От: Robert Haas
Дата:
Сообщение: Re: Rewrite, normal execution vs. EXPLAIN ANALYZE