9.0 EXPLAIN Buffers: written=nnnn

From: <david(dot)sahagian(at)emc(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: 9.0 EXPLAIN Buffers: written=nnnn
Date: 2012-02-02 17:03:20
Message-ID: F3CBFBA88397EA498B22A05FFA9EC49D6468C946@MX22A.corp.emc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Do EXPLAIN ANALYZE:

. . . only showing the bottom node . . .
-> Seq Scan on YYYYY
(cost=0.00..37962.29 rows=876029 width=40)
(actual time=16.728..92555.945 rows=876002 loops=1)
Output: foo, bar
Buffers:
shared hit=146
read=29056
written=2325 !!!!!

"Total runtime: 375542.347 ms"

Then Do EXPLAIN ANALYZE again:

. . . only showing the bottom node . . .
-> Seq Scan on YYYYY
(cost=0.00..37962.29 rows=876029 width=40)
(actual time=0.192..2972.127 rows=876002 loops=1)
Output: foo, bar
Buffers:
shared hit=210
read=28992

"Total runtime: 32913.884 ms"

In general, can you tell me why [written=2325] is displayed by the first EXPLAIN, but not the second EXPLAIN ?
The query is a SELECT, so what is getting "written" ?

Note that both EXPLAINs have the exact same plan. Bottom up is: Seq Scan on YYYY, Hash, Seq Scan on XXXX, Hash Join, HashAggregate

I am wondering if it is a clue as to why the "actual time" is so different from one run to the next.

The query is 2 tables joined, with a group by:
select
sum (case when X.hid is null and not Y.cntr = '0' then 1 else 0 end) as colp
from
xxxxx X
inner join yyyyy Y on Y.coln = X.colm
where
X.some_id = 'aeiou'
group by
X.some_type

Thanks,
-dvs-

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rodrigo Gonzalez 2012-02-02 17:37:34 Re: 9.0 EXPLAIN Buffers: written=nnnn
Previous Message Andrew Sullivan 2012-02-02 15:11:35 Re: Is it possible to speed up addition of "not null"?