First of all, a question:
UPDATE table_a
SET column_d = 100, column_e = 200
WHERE column_a = 1 and column_b = 0 and column_c = 1;
UPDATE table_a
SET column_d = 123, column_e = 150
WHERE column_a = 2 and column_b = 1 and column_c = 3
...
Imagine this goes on.
Would any performance improvement come from merging these in a single query?
If so, how can it be done?
Remember I am asking specifically for SQLlite3
Akina
20.8k2 gold badges20 silver badges22 bronze badges
1 Answer 1
Finding each row to update requires an index lookup. Writing a combined query would not change this.
Minimize the transaction overhead by running all UPDATEs inside a single transaction. Further performance improvements are not possible.
answered Nov 6, 2020 at 12:27
-
Got it, thanks! That was my initial thought. Already following the advice and moving everything to a single transactioncatteneo– catteneo2020年11月06日 16:34:43 +00:00Commented Nov 6, 2020 at 16:34
lang-sql