Re: Weird behavior with selects and composite data types
От | Tom Lane |
---|---|
Тема | Re: Weird behavior with selects and composite data types |
Дата | |
Msg-id | 11511.1095692207@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Weird behavior with selects and composite data types (lists@petri.cc) |
Список | pgsql-general |
lists@petri.cc writes: > When using the (tbl).field notation for selecting a specific field from a > composite field then the query returning the field is executed once per > field. You mean that the function yielding the field is executed repeatedly: > SELECT guid, (acl).read, (acl).write,(acl).list FROM (select guid, > f_all_acl(guid) as acl from rt_host) as i; This will be flattened into SELECT guid, (f_all_acl(guid)).read, (f_all_acl(guid)).write, (f_all_acl(guid)).list FROM rt_host; which is generally a good thing, but perhaps not if f_all_acl() is expensive to compute. The standard hack at present for preventing such flattening without changing the query semantics is to insert an OFFSET 0 clause into the subselect: SELECT guid, (acl).read, (acl).write,(acl).list FROM (select guid, f_all_acl(guid) as acl from rt_host offset 0) as i; Note that this has nothing to do with field selection in particular, it's just a general property of the subselect-in-FROM implementation. regards, tom lane
В списке pgsql-general по дате отправления: