Any point in using LIMIT in EXISTS query?
问题 Is there any performance benefit in adding a LIMIT to an EXISTS query, or would MySQL apply the limit on its own? Example: IF EXISTS ( SELECT 1 FROM my_table LIMIT 1 -- can this improve performance? ) THEN ... END IF; 回答1: The purpose of EXISTS() is to perform the query only until it can decide if there are any rows in that table matching the WHERE clause. That is, it logically does the same thing as LIMIT 1 . EXISTS is probably called semi-join in some circles. Bottom line: Don't use LIMIT 1