pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: Gaetano Mendola <mendola@bigfoot.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: Query optimization path
Date: Sun, 12 Jan 2003 11:01:08 -0600
Message-ID: <20030112170108.GB31080@wolff.to> (raw)
In-Reply-To: <avs593$10j2$1@news.hub.org>
References: <avs593$10j2$1@news.hub.org>

On Sun, Jan 12, 2003 at 17:31:34 +0100,
  Gaetano Mendola <mendola@bigfoot.com> 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.

Outer (and left and right) joins are generally not associative, so the
"JOIN" keyword being required for those cases isn't generally going to
be a problem.



view thread (5+ messages)  latest in thread

Message-ID: <20030112170108.GB31080@wolff.to>
Permalink:  ../20030112170108.GB31080@wolff.to/
Also on:    postgresql.org/message-id/20030112170108.GB31080@wolff.to

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: bruno@wolff.to, mendola@bigfoot.com
  Subject: Re: Query optimization path
  In-Reply-To: <20030112170108.GB31080@wolff.to>
  References: <avs593$10j2$1@news.hub.org> <20030112170108.GB31080@wolff.to>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox