Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 15AF21AC5EFD for ; Thu, 5 Jul 2012 09:23:16 -0300 (ADT) Received: from mail-yw0-f46.google.com ([209.85.213.46]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Sml5T-0002Aj-2n for pgsql-admin@postgresql.org; Thu, 05 Jul 2012 12:23:15 +0000 Received: by yhmm54 with SMTP id m54so8076006yhm.19 for ; Thu, 05 Jul 2012 05:22:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=iJrfkdUMkf2FaIzApcvEy05dTGX0EdZGMqvBWCyzEd4=; b=Y7ZkF23Jh1AdTodWFCqycSt/UEkviOuUApJo236/4vWRq6mOzrtQz5x7FyfC5HA3wM LTxq5+lsKGTdG7NKs6LNwlHr4Fa78nkJbVUnUwZVQyyyMTbYrVA/yOa5agspx/XxAi7Y UtDymd2RegEmAyY7dLc48yrQkCgUSilKjm60a9aDEV/VJMb9Mb5kw2MXmK1ZVwqAoHLN M+S/nwUzqi7zJWY/cJFC+71FqTpMT9qm4c6ukCRyf26+yXtYKRnk5pvfZnFXiY2vLvZZ xxn+32N0NhBQpjDakIckMNfSgRycBeQlkz6R63ycm+CYMzy/Vp4FcWe4Zv/KOP3qi2jQ nGkQ== Received: by 10.68.238.68 with SMTP id vi4mr27601074pbc.123.1341490973966; Thu, 05 Jul 2012 05:22:53 -0700 (PDT) Received: from ayaki.localdomain (124-169-169-118.dyn.iinet.net.au. [124.169.169.118]) by mx.google.com with ESMTPS id ru4sm19677293pbc.66.2012.07.05.05.22.50 (version=SSLv3 cipher=OTHER); Thu, 05 Jul 2012 05:22:52 -0700 (PDT) Message-ID: <4FF58717.2000901@ringerc.id.au> Date: Thu, 05 Jul 2012 20:22:47 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 MIME-Version: 1.0 To: Albe Laurenz CC: Akash Kodibail *EXTERN* , pgsql-admin@postgresql.org Subject: Re: Delay in completion of aggregation inserts when run in a single commit - PG 9.1.2 References: <67A07D932F8DCC41989A050EDE427A210CF9B5@JETWINSRVRPS02.onmobile.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQlC/HzKlkOZEnKP6aqi3j1YMUQ3nzAL/7bmbWS/OrGOgrFo2CPiz5tDcdWmPTAVEWVCOK3l X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201207/21 X-Sequence-Number: 39738 On 07/05/2012 04:00 PM, Albe Laurenz wrote: > Akash Kodibail wrote: >> Problem: > [...] >> - Aggregation process almost never completes which is a set of 15 > insert queries. Entire >> process happens in a single commit (population of staging tables and > aggregation). >> - When I run these 15 queries individually, it happens in no time. >> >> Could you be kind enough to explain how differently queries run when > in a "single commit" as opposed >> to running each of them individually? > Apart from minor differences (current_timestamp, ...) the > main difference is that there is no COMMIT after each query. > COMMIT is expensive since it requires a write to hard disk. > > Try to get the execution plans of the queries in both cases > and see if you can spot a difference. Actually, that's a thought. Autovaccum can't see uncomitted work, and thus can't analyze it. Maybe they need an explicit ANALYZE or two after a bulk insert or update during their data load. -- Craig Ringer