I feel dumb right now.
I got to update 100.000 rows on a database that i don’t have direct access to. The total row count of the table is roughtly 500.000 rows.
The update just adds one caracter to a field in case it’s length is < 3. So Basically:
UPDATE X SET VALUE = ‘0’||VALUE WHERE LENGTH(VALUE) < 3
So i send this update to the DBA’s and they return it to me saying that the statement has too much performance cost (because the full access table and the 100k commit)
and that i should write a proces instead. And then they provide me a code example, in case i don’t know how to make one.
I say WTF, how a process would ever run faster than a single update statement? Afer doing doing some tests, my update takes 30 seconds to run,
the process, following their code example, takes 10 minutes.
So the real question, after all this frustation, is: Is there any way to avoid the full acces table when using such a function in the where clause? (the column is indexed)
Your statement is already optimized. It is set-based and queries the table in the most efficient way possible (Full Table Scan). You won’t be able to write a program that does the same work with less resources / time. You CAN write a program that performs poorly, that is non-restartable in case of error (ie: commit every 100 rows) and will monopolize more resources.
Follow Tom Kyte’s mantra: