Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 5AE24EC7B25 for ; Fri, 6 Jul 2012 02:29:05 -0300 (ADT) Received: from mail-yx0-f174.google.com ([209.85.213.174]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Sn16E-0003Th-Ke for pgsql-admin@postgresql.org; Fri, 06 Jul 2012 05:29:04 +0000 Received: by yenl2 with SMTP id l2so8222366yen.19 for ; Thu, 05 Jul 2012 22:28:48 -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:x-gm-message-state; bh=q43JmQmoDSlZabt/zuUUM0QNZFdqEcn+JAyPtCmob9c=; b=B+isf18ihAoH9Opnhxpc6L5Nr9j2Izn5g2R6OAkUFh7Dh2V1zzsPkfpmJUQY4HSKJP Wyupwft9k3pN9iiyqQozadagodfUKMA94WHoGjCudXbVxiLY9rc6zhLoLeG968Rc1u4X CiCrAUEzAHqXJZsiSQ4m3ayzFJd4QVkXsAvhjaH+BmFFOIHp1MKBEhuGddD4RQ0AwQ3z XSrpb7Bs5LNdFt7hiz05nTpZogyBj0f7Uepicdkdag6wEY7+38Dj1s0qwjFtimhkcIXA Jgv0flb/fL5fX6i7YEv4gONLNmw93HcFnImsrq8T3v+jShrU0YEJ7ViYoQrmfS0dxJ2j uaRA== Received: by 10.66.75.202 with SMTP id e10mr42973596paw.55.1341552528297; Thu, 05 Jul 2012 22:28:48 -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 pq5sm21168769pbb.30.2012.07.05.22.28.45 (version=SSLv3 cipher=OTHER); Thu, 05 Jul 2012 22:28:47 -0700 (PDT) Message-ID: <4FF6778B.8040704@ringerc.id.au> Date: Fri, 06 Jul 2012 13:28:43 +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: Akash CC: pgsql-admin@postgresql.org Subject: Re: Re: Delay in completion of aggregation inserts when run in a single commit - PG 9.1.2 References: <67A07D932F8DCC41989A050EDE427A210CF9B5@JETWINSRVRPS02.onmobile.com> <4FF5354E.8090105@ringerc.id.au> <1341551173972-5715621.post@n5.nabble.com> In-Reply-To: <1341551173972-5715621.post@n5.nabble.com> Content-Type: multipart/alternative; boundary="------------000400060602020708030200" X-Gm-Message-State: ALoCoQkvRvImxJDm471tq2mqfT1E/juE1CRY/w1H6gJvid9vYLJ+TcNxaBgLSF9WyX0caGIS90Hk X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201207/25 X-Sequence-Number: 39742 This is a multi-part message in MIME format. --------------000400060602020708030200 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 07/06/2012 01:06 PM, Akash wrote: > @@Craig > > I could only wait for 6 hours. I cancelled the process after that. > > No locks on any of the tables when running. That's a very ambiguous statement. I'm assuming you are saying "our code does not take any explict locks on those tables using LOCK TABLE or SELECT ... FOR SHARE / FOR UPDATE" - because there /most certainly are/ locks on those tables whenever you're running a query against them. Even a simple SELECT takes out a lock to prevent the table from being dropped while the query runs. There could be no locks taken by transactions other than the transaction doing the run, though. > Yes, It was progressing. Of the 15 tables, when I cancelled after 6 hours, > 3rd table was getting populated (when checked in pg_stat_activity). OK. If you turn auto_explain on and use it to get a plan for the slow queries, do those plans differ from the plans produced when running the same queries standalone? Did you examine iostat? Did you look at what work the postgres process was doing to see if it was busy with cpu or I/O (iowait) or if it was idle waiting for something else to happen? > 4)autovacuum = off, we are doing daily vacuum analyze on all tables. No! Unless your database as /no/ write activity other than these batch loads, you should have autovacuum on. The more frequently autovaccum runs the better a job it will do of preventing bloat, maintaining table stats, etc. If you have tables that are only ever modified by a bulk-load script that then immediately vacuums them, set the autovac parameters for that table so it's excluded, don't turn autovaccum off entirely. > 5)shared_buffers = 32MB That's tiny and will severely constrain Pg's resources. I notice you didn't set effective_cache_size either. > After these changes process is moving forward, but somehow I feel that, It > is only matter of time, I will reach the next choking point. Since I am > seeing the that process completion is taking a little longer each time I run > it. Well, your tables and indexes are probably bloating horribly because autovaccum is turned off, so that's not surprising. If you drop and recreate, or TRUNCATE, the tables between load runs you might be OK with autovac off for those tables, but what you're describing makes me think otherwise. -- Craig Ringer --------------000400060602020708030200 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
On 07/06/2012 01:06 PM, Akash wrote:
@@Craig

I could only wait for 6 hours. I cancelled the process after that.

No locks on any of the tables when running.
That's a very ambiguous statement. I'm assuming you are saying "our code does not take any explict locks on those tables using LOCK TABLE or SELECT ... FOR SHARE / FOR UPDATE" - because there most certainly are locks on those tables whenever you're running a query against them. Even a simple SELECT takes out a lock to prevent the table from being dropped while the query runs.

There could be no locks taken by transactions other than the transaction doing the run, though.

Yes, It was progressing. Of the 15 tables, when I cancelled after 6 hours,
3rd table was getting populated (when checked in pg_stat_activity).
OK. If you turn auto_explain on and use it to get a plan for the slow queries, do those plans differ from the plans produced when running the same queries standalone?

Did you examine iostat? Did you look at what work the postgres process was doing to see if it was busy with cpu or I/O (iowait) or if it was idle waiting for something else to happen?

4)autovacuum = off, we are doing daily vacuum analyze on all tables.
No!

Unless your database as no write activity other than these batch loads, you should have autovacuum on. The more frequently autovaccum runs the better a job it will do of preventing bloat, maintaining table stats, etc.

If you have tables that are only ever modified by a bulk-load script that then immediately vacuums them, set the autovac parameters for that table so it's excluded, don't turn autovaccum off entirely.


5)shared_buffers = 32MB
That's tiny and will severely constrain Pg's resources.

I notice you didn't set effective_cache_size either.
After these changes process is moving forward, but somehow I feel that, It
is only matter of time, I will reach the next choking point. Since I am
seeing the that process completion is taking a little longer each time I run
it.
Well, your tables and indexes are probably bloating horribly because autovaccum is turned off, so that's not surprising.

If you drop and recreate, or TRUNCATE, the tables between load runs you might be OK with autovac off for those tables, but what you're describing makes me think otherwise.

--
Craig Ringer
--------------000400060602020708030200--