Answer the question
In order to leave comments, you need to log in
How will the query run faster?
Hello.
Let's say we have a table. For the example, one bit column is sufficient.
0
0
0
0
1
I need to execute an update query, which will replace all values of 1 with
0
It's just that I imagine an algorithm with a condition like this
iteration of lines
If field = 1 then field = 0
next line
and an algorithm without a condition so
iteration of lines
field = 0
next line
So, which query will run faster? What takes more time, overwriting the value or comparing? After all, if the same amount of time is spent, then in the case of the condition there will be 1 more operation (besides comparison, it will also be overwritten)
Answer the question
In order to leave comments, you need to log in
It remains only to think about how it will be with the version with the index. :)
Good afternoon.
It will be faster to filter by field, and then update the fields (you need an index by field for good work speed, you need to overlay the field with an index)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question