As titled, if there is only one record in table, are the two querys identical:
select * from table limit 10;
select * from table limit 100000;
thanks.
As titled, if there is only one record in table, are the two querys identical:
select * from table limit 10;
select * from table limit 100000;
thanks.
I dont know the implementation of LIMIT in mysql but based on below links, i think it will not difference if the query returns less than LIMIT.
Does adding 'LIMIT 1' to MySQL queries make them faster when you know there will only be 1 result?
putting limit in this case will not effect your end result. But you should be aware that putting limit in a query does impact the performance of a query.
I have not researched about mysql
, but in context with Postgresql
, there is a difference, but not much to be considered.
You can see the difference by prefixing your query with
EXPLAIN ANALYZE
, it will output QUERY PLAN
.
=# EXPLAIN ANALYZE select * from table limit 10;
=# EXPLAIN ANALYZE select * from table limit 100000;
This will give you parameters like
There might be something available for mysql
as well.
I hope this will help.
It won't affect your end result but if you know you only have one record then it'd be better not to use limit because if you set limit to 100 it'll reserve extra 99 pointers in memory.
Do not put limit because it limited the records appear on your screen so try to avoid if in future you want to get more records it will make problem for you. Also if you want query faster and more efficient use limit number you want to show in your page as per your requirement