I guess the main reason for this is to limit the optimizer overhead for very simple statements.However, this also means that optimization opportunities are sometimes missed for more complex UPDATE/DELETE statements.I let the above query run for more than an hour and it still did not complete.Can you suggest a way to rewrite this query to avoid the WHERE EXISTS? I am unable to update my production server at this time but can try v10 Summit in a test system tomorrow if you think it is a version issue. Selector .selector_input_interaction .selector_input. Selector .selector_input_interaction .selector_spinner. In My SQL, query optimization of single-table UPDATE/DELETE statements is more limited than for SELECT statements.Because of this indeterminacy, referencing other tables only within sub-selects is safer, though often harder to read and slower than using a join.Attempt to insert a new stock item along with the quantity of stock.
A similar select query using the same join took about 5 seconds.Unlike single-table UPDATE statements, the My SQL Optimizer will use all available optimizations for multi-table UPDATE statements.I am relatively new to SQL and would appreciate your insight on formulated the following statement.If the item already exists, instead update the stock count of the existing item.To do this without failing the entire transaction, use savepoints: BEGIN; -- other operations SAVEPOINT sp1; INSERT INTO wines VALUES('Chateau Lafite 2003', '24'); -- Assume the above fails because of a unique key violation, -- so now we issue these commands: ROLLBACK TO sp1; UPDATE wines SET stock = stock 24 WHERE winename = 'Chateau Lafite 2003'; -- continue with other operations, and eventually COMMIT; If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.