pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Vitalii Tymchyshyn <tivv00@gmail.com>
To: pgsql-performance@postgresql.org
Subject: Re: Long Running Update
Date: Fri, 24 Jun 2011 14:45:15 +0300
Message-ID: <4E0478CB.8080002@gmail.com> (raw)
In-Reply-To: <4E047210.4020400@riskcontrollimited.com>
References: <4E035649.20007@riskcontrollimited.com>
	<4E034E78020000250003EB37@gw.wicourts.gov>
	<4E047210.4020400@riskcontrollimited.com>

24.06.11 14:16, Harry Mantheakis написав(ла):
>
> > EXPLAIN the statement
>
> Here is the EXPLAIN result:
>
> ----------------------------------------------------------------------
> QUERY PLAN
> ----------------------------------------------------------------------
> Hash Join (cost=2589312.08..16596998.47 rows=74558048 width=63)
> Hash Cond: (table_A.id = table_B.id)
> -> Seq Scan on table_A(cost=0.00..1941825.05 rows=95612705 width=47)
> -> Hash (cost=1220472.48..1220472.48 rows=74558048 width=20)
> -> Seq Scan on table_B(cost=0.00..1220472.48 rows=74558048 width=20)
> ----------------------------------------------------------------------
>
> The documentation says the 'cost' numbers are 'units of disk page 
> fetches'.
>
> Do you, by any chance, have any notion of how many disk page fetches 
> can be processed per second in practice - at least a rough idea?
>
> IOW how do I convert - guesstimate! - these numbers into (plausible) 
> time values?
No chance. This are "virtual values" for planner only.
If I read correctly, your query should go into two phases: build hash 
map on one table, then update second table using the map. Not that this 
all valid unless you have any constraints (including foreign checks, 
both sides) to check on any field of updated table. If you have, you'd 
better drop them.
Anyway, this is two seq. scans. For a long query I am using a tool like 
ktrace (freebsd) to get system read/write calls backend is doing. Then 
with catalog tables you can map file names to relations 
(tables/indexes). Then you can see which stage you are on and how fast 
is it doing.
Note that partially cached tables are awful (in FreeBSD, dunno for 
linux) for such a query - I suppose this is because instead on 
sequential read, you get a lot of random reads that fools prefetch 
logic. "dd if=table_file of=/dev/null bs=8m" helps me a lot. You can see 
it it helps if CPU time goes up.

Best regards, Vitalii Tymchyshyn



view thread (16+ messages)  latest in thread

Message-ID: <4E0478CB.8080002@gmail.com>
Permalink:  ../4E0478CB.8080002@gmail.com/
Also on:    postgresql.org/message-id/4E0478CB.8080002@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tivv00@gmail.com
  Subject: Re: Long Running Update
  In-Reply-To: <4E0478CB.8080002@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox