Re: Left Join Question

Поиск
Список
Период
Сортировка
От Ryan Wells
Тема Re: Left Join Question
Дата
Msg-id 52F2AD70C422474B857FC9E3F7B62539028DB1F9@exchange.DOCS.COM
обсуждение исходный текст
Ответ на Re: Left Join Question  (Richard Huxton <dev@archonet.com>)
Список pgsql-sql
Thanks for the feedback, everyone.

> > FROM tasks
> >  LEFT JOIN clients ON tasks.ClientId = clients.ClientId
> >   LEFT JOIN iteminfo ON tasks.Id = iteminfo.ItemId
> >    LEFT JOIN changelog ON tasks.Id = changelog.ItemId
> >     LEFT JOIN ticklers ON tasks.Id = ticklers.RelatedId
> > WHERE tasks.Id = '123456';
> >
> > (I've cleaned it up so it's  easier to read.)
>
> Thanks Ryan - that always makes it easier.

It actually looked so much less crazy after the cleaning that I nearly
decided not to ask about it, but my I was really interested in learning
if there was a dramatically better approach.  Looks like there probably
isn't, which is fine.

> For the case when you have large numbers of results from iteminfo etc.
> it might well be quicker to do separate queries. That's simple enough
> since you're joining straight to tasks.id, but is obviously more
fiddly
> and when there aren't many rows returned would probably be slower
(you'd
> have 5 lots of query parsing/execute overhead). That might be a
> trade-off that makes sense to you though.

Even though the tables are fairly big, the result-set should be small (a
few dozen maybe), so multiple queries probably wouldn't gain much.

Thanks again!
Ryan


В списке pgsql-sql по дате отправления:

Предыдущее
От: "A. Kretschmer"
Дата:
Сообщение: Re: custom serial number
Следующее
От: "Sabin Coanda"
Дата:
Сообщение: VACUUM cannot be executed from multi-command string