I am new to query optimization,how to use semi join while implementing decorrelation I can't totally understand.
Consider the query
SELECT A, B
FROM r
WHERE r.B < SOME (
SELECT B
FROM s
WHERE s.A = r.A
)
Show how to decorrelate the above query using the multi-set version of the semi-join operation
You may write your query using an inner join as follows:
The
DISTINCTclause is necessary in this version of your query, because a given record in thertable could potentially join to more than one match in thestable. In your original version, there can't be duplicates, because of theSOMEclause which take a set of records any always returns a single yes/no answer.