PDO :: fetch () LIMIT 1

Is it necessary to write LIMIT 1 using the PDO fetch() method? This suggests that I need only one result. I am wondering if LIMIT 1 helps save resources and load time?

+4
source share
3 answers

This can help you. http://dev.mysql.com/doc/refman/5.0/en/limit-optimization.html is very clear on this topic.

+4
source

The LIMIT clause is another SQL function that you can use to get the information you need. If you ask if you need a LIMIT, it will not make much sense to ask if you need WHERE or JOIN. It depends on your details and your request.

I do not know if this is so, but I have seen too many newbies who do not know more SQL than SELECT * FROM table . Just try to learn basic SQL and return the query to the desired rows and columns.

+2
source

The limit is applied after the query is completed, so it will not really reduce the resources used by the database server. However, this will reduce the amount of resources PHP uses to store the result.

-2
source

All Articles