SQL query with limit 0

I think it is for parsing query only.

In simple approach The query execution steps are :

  1. Parsing query
  2. Make execution plan(including select best index to use).
  3. Fetch data from disk.

I finally found some knowledgeable thing,when I have created a demo for you,use below mentioned fiddle to check the execution plan when comparing with limit 0 and 1.

http://sqlfiddle.com/#!9/82a8f0/5

What I have seen is that,in execution if we use Limit 0 than its not taking consideration of Table.check my sqlfiddle mentioned above.

Note : I have created only simple table to check Execution Plan difference in demo.


As per MySQL docs:
LIMIT 0 quickly returns an empty set. This can be useful for checking the validity of a query. It can also be employed to obtain the types of the result columns if you are using a MySQL API that makes result set metadata available.

Tags:

Sql