Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 886CAB5DBF2 for ; Fri, 24 Jun 2011 08:45:43 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 91827-09 for ; Fri, 24 Jun 2011 11:45:37 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-fx0-f46.google.com (mail-fx0-f46.google.com [209.85.161.46]) by mail.postgresql.org (Postfix) with ESMTP id 3D30CB5D803 for ; Fri, 24 Jun 2011 08:45:37 -0300 (ADT) Received: by fxm17 with SMTP id 17so1821723fxm.19 for ; Fri, 24 Jun 2011 04:45:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=+iRUWF4+K49AWWioq2br9c0V0CR9cCUHTj7EhmotDdc=; b=iOULNK3z1t1DMIIshKIiFlM2yDRPoloPC6SBU/EY2WgFTdACqyT6LZnqoUc0u+YqPz lTzZHnQvsZKxoSd5KIRGCSzwtoxSQU2HPu0W2nFPm1mYe06ZasStuj06oUM1S8L24TBt cZ0TPsqYBZSRTNIfkp6HazMyyxbpW1rg+2mUs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=HBuVP1VauS1ARQaSmI13FrY8RsEVaWs8Wir4TOe8cuJ1EdyiWAba9bmlH/aX/JEOim 3SeRx0+bCvrUu0jfuLHwL/UDiQIwwS2ynBUe6AzzvCi7lUOyhPkzjMaj3DyzO10ElO8s wiVRucy6F1oMS3TCLz3cpz8lCX3ITVhgQ8DEQ= Received: by 10.223.1.10 with SMTP id 10mr3960995fad.134.1308915936925; Fri, 24 Jun 2011 04:45:36 -0700 (PDT) Received: from [10.64.1.26] ([213.108.72.250]) by mx.google.com with ESMTPS id 10sm1599504faw.0.2011.06.24.04.45.27 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 24 Jun 2011 04:45:35 -0700 (PDT) Message-ID: <4E0478CB.8080002@gmail.com> Date: Fri, 24 Jun 2011 14:45:15 +0300 From: Vitalii Tymchyshyn User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Long Running Update References: <4E035649.20007@riskcontrollimited.com> <4E034E78020000250003EB37@gw.wicourts.gov> <4E047210.4020400@riskcontrollimited.com> In-Reply-To: <4E047210.4020400@riskcontrollimited.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.335 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_ENVFROM_END_DIGIT=1.553, FREEMAIL_FROM=0.001, RFC_ABUSE_POST=0.001, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201106/225 X-Sequence-Number: 44158 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