UPDATE category SET is_leaf=1 WHERE id=9 AND is_leaf=0
is more efficient. because then it update only relevant data. otherwise even if the is_leaf=1
records are also going to update.
Assume that there are 1000 record on the table and it take 1s to update one record. if u trying to update all records then it will take 1000 S. but assume in this scenario there are is_leaf=0
record count is 150 then if you use this second statement it will take only 150 seconds instead of 1000 s.
Edit :
Queries With Search Arguments (SARGs)
A WHERE clause helps you to restrict the number of rows returned by a query. However, the manner in which the WHERE condition is specified can impact the performance of the query. If the WHERE condition is written such that it uses a function that takes an indexed column as the input, then the index is ignored and the entire table is scanned. This results in performance degradation.
For example, the following results in a table scan because the column OrderDate is used in a function:
SELECT CustomerID, EmployeeID FROM Orders
WHERE DATEDIFF(m, OrderDate, GetDate())>3
If the function is rewritten as shown below, then the query seeks the required value using an index and this improves performance:
SELECT CustomerID, EmployeeID FROM Orders
WHERE OrderDate < DATEADD(m, -3, GetDate())
The filter criteria in the second query is said to use a Searchable Argument or SARG because the query optimizer can use an index seek operation during execution.
for more information about this you better read improving query performance
and also read this for Speeding up Searches and Filters