| От | Tom Lane |
|---|---|
| Тема | Re: Postgres8: subselect and optimizer/planner |
| Дата | |
| Msg-id | 20074.1191507505@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Postgres8: subselect and optimizer/planner (Erwin Moller <erwin@darwine.nl>) |
| Список | pgsql-general |
Erwin Moller <erwin@darwine.nl> 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
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера