Received: from maia.hub.org (maia-1.hub.org [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 5729063372C for ; Mon, 10 May 2010 18:35:26 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 45217-07 for ; Mon, 10 May 2010 21:35:13 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-yw0-f189.google.com (mail-yw0-f189.google.com [209.85.211.189]) by mail.postgresql.org (Postfix) with ESMTP id 1D5866335EE for ; Mon, 10 May 2010 18:35:19 -0300 (ADT) Received: by ywh27 with SMTP id 27so2143626ywh.20 for ; Mon, 10 May 2010 14:35:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=bfYyVb59KXfXLmbfYGzWO1XLNzsjGNUPN5Zk5gHABhI=; b=pAqYxIDVnWu6yGDpcwX3byOpF3qjkktpyEexv0U5qFVJzqwRdTebyHOr0QTvlmd9CG xUYjLu6JWM1en0QT1Q3IjUY84ck7fforWqhLFo/HVzNDYLv0n4YBhJ/i4UczSsDIqKeL BecRfGjqOQmyhpl3tiW7nu7k68+LLJQ2jr+Hg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=rq5xkXwuPKxA4ake7FE/GUMoZe5GRrPKpgW/iWdqseOqcOfAEUCHFNP7lZFhA7QMjN bPZ70nObnqplL5HZtnb6zDxair9Qi2Hn/zaDQM+yFbfoCW1lUDyoZgI1CfG5PgIsL/AX /yVCuCr3RCdDw56K/ECuRHM7nRBQMOVRMC3Tg= MIME-Version: 1.0 Received: by 10.151.25.16 with SMTP id c16mr6968845ybj.363.1273527317636; Mon, 10 May 2010 14:35:17 -0700 (PDT) Received: by 10.150.185.5 with HTTP; Mon, 10 May 2010 14:35:17 -0700 (PDT) In-Reply-To: <4BE86EBA.3070205@fmed.uba.ar> References: <4BE8530C.6030605@fmed.uba.ar> <4BE86EBA.3070205@fmed.uba.ar> Date: Mon, 10 May 2010 15:35:17 -0600 Message-ID: Subject: Re: advice on query joining 10 tables From: Scott Marlowe To: Gerardo Herzig Cc: postgres list Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201005/37 X-Sequence-Number: 34085 On Mon, May 10, 2010 at 2:38 PM, Gerardo Herzig wrote= : > Scott Marlowe wrote: >> On Mon, May 10, 2010 at 12:40 PM, Gerardo Herzig w= rote: >>> Hi all. Im triyng to see if i can improve the performance of a query >>> (mainly a 10 table join) >>> >>> 1) Besides of triyng to use indexes, there is some rules of thumb to fo= llow? >> >> log long running queries for later analysis? >> >>> 2) Should i try to join the bigger tables last in the query? >> >> The query planner can do that for you automatically. >> >>> 3) There is some place for understanding EXPLAIN better? >> >> http://explain.depesz.com/ >> >> Here and the docs? =A0I've found it pretty easy to post one here and ask >> for help and get it on why a query isn't running well. =A0Note that >> explain analyze is much preferred to plain explain. >> > Well, thanks Tom and Scott for the answers. I will take some more time > reading the docs. Im looking more to know better, rather than just > waiting to someone to point out my errors. Also, search the pgsql archives for "explain analyze" for lots of posts. You can learn quite a bit trawling the archives like that.