Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A3040476086 for ; Sun, 12 Jan 2003 12:28:32 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 2DB5B475E71 for ; Sun, 12 Jan 2003 12:28:32 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 4E922D5F7; Sun, 12 Jan 2003 09:28:37 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 404EF5C02; Sun, 12 Jan 2003 09:28:37 -0800 (PST) Date: Sun, 12 Jan 2003 09:28:37 -0800 (PST) From: Stephan Szabo To: Gaetano Mendola Cc: Subject: Re: Query optimization path In-Reply-To: Message-ID: <20030112092638.H41588-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/111 X-Sequence-Number: 6953 On Sun, 12 Jan 2003, Gaetano Mendola wrote: > "Bruno Wolff III" wrote in message > news:20030112170108.GB31080@wolff.to... > > Gaetano Mendola wrote: > > > Hi all, > > > > > > I have the following query: > > > > > > SELECT count(1) > > > FROM providers p JOIN class_default cd USING (id_provider) > > > JOIN user_data ud USING (id_class) > > > JOIN v_user_traffic ut USING (id_user) > > > WHERE id_user_status in (4,5) AND > > > p.company = 'XXXXX'; > > > > > > is not slow but I notice that if I do explain analyze with the table > > > reordered > > > inside the select in another way the cost change. > > > Using "JOIN" fixes the order that tables are joined in. If you are > > just doing inner joins, then you probably don't want to use the "JOIN" > > keyword. The exception being when there are so many tables being joined > > that you want to manually specify at least some of the join ordering in > > order to help out the planner. > > And where is written this behavior ? Is it SQL standard ? http://www.postgresql.org/idocs/index.php?explicit-joins.html The standard generally has nothing to say about optimization.