Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id C4DF41337B68 for ; Thu, 3 Feb 2011 11:43:54 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 85887-10 for ; Thu, 3 Feb 2011 15:43:49 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from marajade.localdomain (vcs5.camavision.com [63.228.164.252]) by mail.postgresql.org (Postfix) with ESMTP id 64149133740B for ; Thu, 3 Feb 2011 11:43:47 -0400 (AST) Received: from [192.168.10.84] (unknown [192.168.10.84]) (Authenticated sender: andy) by marajade.localdomain (Postfix) with ESMTPA id B9E944079D; Thu, 3 Feb 2011 09:43:47 -0600 (CST) Message-ID: <4D4ACD43.6050000@squeakycode.net> Date: Thu, 03 Feb 2011 09:44:03 -0600 From: Andy Colson User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101207 Lightning/1.0b2 Thunderbird/3.1.7 MIME-Version: 1.0 To: Mark Stosberg CC: pgsql-performance@postgresql.org Subject: Re: getting the most of out multi-core systems for repeated complex SELECT statements References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 X-Spam-Level: X-Archive-Number: 201102/79 X-Sequence-Number: 42217 On 2/3/2011 9:08 AM, Mark Stosberg wrote: > > Each night we run over a 100,000 "saved searches" against PostgreSQL > 9.0.x. These are all complex SELECTs using "cube" functions to perform a > geo-spatial search to help people find adoptable pets at shelters. > > All of our machines in development in production have at least 2 cores > in them, and I'm wondering about the best way to maximally engage all > the processors. > > Now we simply run the searches in serial. I realize PostgreSQL may be > taking advantage of the multiple cores some in this arrangement, but I'm > seeking advice about the possibility and methods for running the > searches in parallel. > > One naive I approach I considered was to use parallel cron scripts. One > would run the "odd" searches and the other would run the "even" > searches. This would be easy to implement, but perhaps there is a better > way. To those who have covered this area already, what's the best way > to put multiple cores to use when running repeated SELECTs with PostgreSQL? > > Thanks! > > Mark > > 1) I'm assuming this is all server side processing. 2) One database connection will use one core. To use multiple cores you need multiple database connections. 3) If your jobs are IO bound, then running multiple jobs may hurt performance. Your naive approach is the best. Just spawn off two jobs (or three, or whatever). I think its also the only method. (If there is another method, I dont know what it would be) -Andy