Not the answer you need?
Register and ask your own question!


smaressmares EntrantInactive User Role Beginner
Given a table with a primary key, if I do an UPDATE with WHERE `primaryKey` = "unique value", would LIMIT 1 give any speed optimization? I was told that LIMIT 1 would speed up the query under certain circumstances but if so, under which circumstances?


  • scott.nemesscott.nemes MySQL Sage Current User Role Patron
    Hi smares;

    The LIMIT 1 clause would cause the update to stop as soon as it found the first (and likely only) matching row in your case. So depending on the size of the table and your hardware, it could speed things up significantly. However if your DB is already very fast, and the table is not very large, you may see no difference. But planning for future growth / scalability is always good, so even if you see no significant difference now it would not hurt to leave it as a future safeguard.

Sign In or Register to comment.

MySQL, InnoDB, MariaDB and MongoDB are trademarks of their respective owners.
Copyright ©2005 - 2020 Percona LLC. All rights reserved.