[odb-users] Question about join type for polymorphic objects
boris at codesynthesis.com
Fri May 8 16:26:47 EDT 2015
Енакаев Алексей <Aleksey.Enakaev at infotecs.ru> writes:
> SELECT * FROM "employee" LEFT JOIN "person" ON "person"."id" =
> "person"."id" ... etc.
> And doesn't is look more reasonable to use INNER JOIN always for
> this kind of objects?
Yes, for all intents and purposes this is an INNER JOIN. And it
shouldn't be any slower, in theory. However, in practice, the
implementations seem to do a better job optimizing more commonly-
used LEFT JOINs than INNER JOINs. So I am reluctant to
just change this.
> but PostgreSQL can not use "LEFT JOIN" with "FOR UPDATE".
> Is there any way to explicit join type for polymorphic objects?
Not at the moment. What you could do, however, is create a
"for update" object loading view that would include that
"FOR UPDATE OF ..." clause once in the query condition. This
way you won't have to keep repeating it in your query
construction code. Object loading views (Section 10.2) were
added to handle stuff like this.
More information about the odb-users