The question should be clear enough, but is it of any advantage to use instead of
SELECT 1 FROM table ...
SELECT 1 FROM table ... LIMIT 1
?
The LIMIT clause is used to specify the number of records to return. The LIMIT clause is useful on large tables with thousands of records. Returning a large number of records can impact performance.
In Denodo,at this moment Limit is only supported at the end of a SELECT statement to reduce the size of the result set but it cannot be used in subqueries.
Yes, you will notice a performance difference when dealing with the data. One record takes up less space than multiple records.
Reducer will not run if we use limit in select clause.
Let's say your table has a million rows...
SELECT 1 FROM table ...
Will return the value 1
, a million times...
SELECT 1 FROM table ... LIMIT 1
Will return the value 1
, one time.
EDIT
You mention that you're specifically interested in regards to an EXISTS
check. EXISTS
stops processing after the first row is found (which is why EXISTS
is more efficient than IN
in this case), so with this in mind, there isn't a functional difference between these two queries:
SELECT *
FROM tableA ta
WHERE EXISTS (
SELECT 1
FROM TableB tb
WHERE tb.ID = ta.ID
);
And
SELECT *
FROM tableA ta
WHERE EXISTS (
SELECT 1
FROM TableB tb
WHERE tb.ID = ta.ID
LIMIT 1
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With