Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 5533E1337C02 for ; Sun, 10 Apr 2011 23:29:05 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 17376-04 for ; Mon, 11 Apr 2011 02:28:47 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.187]) by mail.postgresql.org (Postfix) with ESMTP id AE9E81337C06 for ; Sun, 10 Apr 2011 23:28:46 -0300 (ADT) Received: from [192.168.1.6] (mail.highperformancepostgresql.com [71.179.240.8]) by mrelayeu.kundenserver.de (node=mreu0) with ESMTP (Nemesis) id 0MN8wu-1QFjdO3IC0-0078o5; Mon, 11 Apr 2011 04:28:47 +0200 Message-ID: <4DA2679D.5000207@2ndQuadrant.com> Date: Sun, 10 Apr 2011 22:29:49 -0400 From: Greg Smith User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20110307 Icedove/3.0.11 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Multiple index builds on same table - in one sweep? References: <4325.1302369004@sss.pgh.pa.us> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:5usVq53UvMAJGrz+f/t9q2SKEF8SbG8k36WMw2VDWsZ lNELDpmjb7TtMlwpIngjm/A+VmTqmpoelPZHnL+Mh+cDUNUesB 25tJ170BgeYer0+q6HAGck2peeUi5031BYrH6LjmTEJ3s76bhb +t3jLqEq01FIzHJbc6E5678wecegHLXVyqzZy+oNBnvf/LLinS PPU5ygsPVSnhCWEs8Jdnu2zhPrhLNWU+2LMVeWwUOo= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201104/99 X-Sequence-Number: 43161 On 04/09/2011 01:23 PM, Chris Ruprecht wrote: > Maybe, in a future release, somebody will develop something that can create indexes as inactive and have a build tool build and activate them at the same time. Food for thought? > Well, the most common case where this sort of thing happens is when people are using pg_restore to load a dump of an entire database. In that case, you can use "-j" to run more than one loader job in parallel, which can easily end up doing a bunch of index builds at once, particularly at the end. That already works about as well as it can because of the synchronized scan feature Tom mentioned. I doubt you'll ever get much traction arguing for something other than continuing to accelerate that path; correspondingly, making your own index builds look as much like it as possible is a good practice. Fire up as many builds as you can stand in parallel and see how many you can take given the indexes+data involved. It's not clear to me how a create as inactive strategy could improve on that. There are some types of index build operations that bottleneck on CPU operations, and executing several of those in parallel can be a win. At some point you run out of physical I/O, or the additional memory you're using starts taking away too much from caching. Once you're at that point, it's better to build the indexes on another pass, even if it requires re-scanning the table data to do it. The tipping point varies based on both system and workload, it's very hard to predict or automate. -- Greg Smith 2ndQuadrant US greg@2ndQuadrant.com Baltimore, MD PostgreSQL Training, Services, and 24x7 Support www.2ndQuadrant.us "PostgreSQL 9.0 High Performance": http://www.2ndQuadrant.com/books