博文

目前显示的是标签为“minus”的博文

Minus operator versus 'not exists' for faster SQL query

From: h t t p s : // forums .oracle.com/thread/19816 It really depends on a bunch of factors. A MINUS will do a full table scan on both tables unless there is some criteria in the where clause of both queries that allows an index range scan. A MINUS also requires that both queries have the same number of columns, and that each column has the same data type as the corresponding column in the other query (or one convertible to the same type). A MINUS will return all rows from the first query where there is not an exact match column for column with the second query. A MINUS also requires an implicit sort of both queries NOT EXISTS will read the sub-query once for each row in the outer query. If the correlation field (you are running a correlated sub-query?) is an indexed field, then only an index scan is done. The choice of which construct to use depends on the type of data you want to return, and also the relative sizes of the two tables/queries. If the outer table ...