Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id BF586633427 for ; Mon, 1 Feb 2010 16:25:53 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 51280-10 for ; Mon, 1 Feb 2010 20:25:43 +0000 (UTC) X-Greylist: delayed 05:03:26.953993 by SQLgrey-1.7.6 Received: from mail-ww0-f46.google.com (mail-ww0-f46.google.com [74.125.82.46]) by mail.postgresql.org (Postfix) with ESMTP id 233BD6332A3 for ; Mon, 1 Feb 2010 16:25:42 -0400 (AST) Received: by wwi18 with SMTP id 18so550826wwi.19 for ; Mon, 01 Feb 2010 12:25:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=vaLVfj8ZSQGBv+Z+Ckqqnwly9JidL1HvLdYe6U2f//I=; b=t80AOL7z5Y3qjYOVn59a1lq3r1N1gq/b2v9H7rHithWLSjdl/BZ9iXHWt6szQ3fOl8 QP3+JJDQEB9Mo7zEi6UBf8B+dlKNosf2FrBhSb6S6CBydq17rC0QMoMACE3Zsnj/ImQS HoIv3Zr74SQqzzCfTdtilmaZFxnnzU0e6cr+o= 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; b=DjXkhisJW4hF98lhP/HiUO+HbNfmYTYbN7SuC2xyRR9eYxP8P4GwVwDOzKfz0ueZEc gMZ99Fy6K2c32pTV6ByKPaX5oQ9bGHd8zDsCOSR807SrO2k9rmj0DDJL/uD6i41Y5+b0 MhkAp4mMtSt+vRoNLNj+43uo4gqIxujAJdeV0= MIME-Version: 1.0 Received: by 10.216.88.202 with SMTP id a52mr78450wef.101.1265055941324; Mon, 01 Feb 2010 12:25:41 -0800 (PST) In-Reply-To: References: <995516.81823.qm@web113717.mail.gq1.yahoo.com> Date: Mon, 1 Feb 2010 13:25:41 -0700 Message-ID: Subject: Re: combine SQL SELECT statements into one From: Scott Marlowe To: Igor Neyman Cc: Chris.Ellis@shropshire.gov.uk, neilstylz@yahoo.com, pgsql-general@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201002/48 X-Sequence-Number: 158824 On Mon, Feb 1, 2010 at 12:09 PM, Igor Neyman wrote: > Original poster asked for the sql that will touch inventory table only > once. > > Your statement (with 3 subqueries) will do it 3 times. I'm pretty sure that starting with 8.3 the engine will collapse all those into one seq scan internally.