Does appended LIMIT 1
after query have any performance boost?
...if there could be only one possible entry that matched (WHERE
clause for primary key)?
SELECT `x`
FROM `unicorns`
WHERE `id` = 123
LIMIT 1
...the same, but now it's DELETE
:
DELETE FROM `unicorns`
WHERE `id` = 123
LIMIT 1
...and UPDATE
:
UPDATE `unicorns`
SET `rainbows` = `rainbows` + 1
WHERE `id` = 123
LIMIT 1
P.S. Column id
is primary key so it's unique.
Thanks in an advice!
it depends do you have index on column or not
DELETE FROM `unicorns` WHERE `id` = 123 LIMIT 1
is pointless if id is Primary Key, but
DELETE FROM `unicorns` WHERE `noindexoclumn` = 123 LIMIT 1
will give u perfomance boost
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With