Search Postgresql Archives

Re: Postgres8: subselect and optimizer/planner

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Erwin Moller <erwin@xxxxxxxxxx> writes:
> SELECT U.userid, U.username,
> (SELECT G.groupname FROM tblgroup WHERE (G.userid=U.userid)) AS ingroup
> FROM tbluser WHERE (bla..bla...);

> Will this approach be slower than a regular join?

Probably; it's unlikely to be faster anyway.  The best plan you'll get
from this is equivalent to a nestloop with inner indexscan on
tblgroup.userid.  Now that might be the best plan anyway, or it might
not --- if you are selecting many rows from ingroup it's likely to suck.

> Or is my question too general and is the answer 'it depends'?

The only way I could see for this way to win would be if a nestloop is
actually the fastest plan, but the planner misestimates and decides to
use merge or hash join instead.  Which could happen :-(

			regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org/

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux