Richard Huxton wrote:
Sebastian Böck wrote:
But why is the scan on table b performed?
If i understand it correctly this is unnecessary because the
result contains only rows from table a.


It's only unnecessary in the case where there is a 1:1 correspondence between a.id and b.id - if you had more than one matching row in "b" then there'd be repeated rows from "a" in the result. Not sure if PG can tell what the situation is regarding references and pkeys, but in your example you don't have one anyway.

Ok, is there a way to avoid the extra scan if only one row is returned (distinc on for example)?

What would be great is if a subselect could work with more than
one column returning. Is there a way to achieve this?

Thanks Sebastian


---------------------------(end of broadcast)--------------------------- TIP 7: don't forget to increase your free space map settings

Reply via email to