Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check if SAVE_LIMIT is bigger than 0 before running any queries.
On MS SQL Server, the select_for_update() query below will take a ROWLOCK,UPDLOCK on every row in the Task table. This happens because it locks every row it needs to look at to return the result of the query. Since there is no index on the default sorting column "stopped", it has to do a full table scan, and hence it will take rowlocks on each row in the table. On other databases, it will still do a full table scan, but without the excessive locking. If SAVE_LIMIT is 0 the result of this query is unused, so by moving the check a level higher we avoid running this expensive query.
- Loading branch information