Re: Wrong plan or what ? - Mailing list pgsql-admin

From HansH
Subject Re: Wrong plan or what ?
Date
Msg-id bftml3$vmq$1@news.cistron.nl
Whole thread Raw
In response to Wrong plan or what ?  ("Mendola Gaetano" <mendola@bigfoot.com>)
List pgsql-admin
In response to "Mendola Gaetano":
> I'm running Postgres7.3.3 and I'm performing this simple select:

Looking at your fast three step plan
> SELECT id_class from class_default where id_provider = 39;
> SELECT id_user from user_data where id_class in ( 48 );
> SELECT * from user_logs where id_user in (
>  10943,   10942,   10934,   10927,   10910,  10909 );
I'ld stem for reordering the from and where clauses alike:
    select *
    from
           class_default cd,
           user_data ud,
           user_logs ul
    where
           cd.id_provider = 39 and
           ud.id_class = cd.id_class and
           ul.id_user = ud.id_user;

Personally I dislike implied joins and rather go for _about_ this:
    select *
    from
           ( class_default cd
           LEFT JOIN user_data ud ON ud.id_class = cd.id_class )
           LEFT JOIN user_logs ul  ON ul.id_user = ud.id_user,
    where
           cd.id_provider = 39;

Good luck,

HansH





pgsql-admin by date:

Previous
From: Daniel Gerardo Lucero Baylon
Date:
Subject: Starting PostgreSQL server as root
Next
From: "John P. Looney"
Date:
Subject: