An ex-coworker of mine wrote the following UPDATE
as part of a data import script and it takes nearly 15 minutes to complete on a table of 92k rows.
UPDATE table
SET name = (
SELECT TOP 1 old_name FROM (
SELECT
SUM(r) rev,
number,
name,
intermediate_number,
intermediate_name,
old_number,
old_name
FROM table
GROUP BY
number,
name,
intermediate_number,
intermediate_name,
old_number,
old_name
) t
WHERE t.name = table.name
ORDER BY rev DESC
);
I'm sure it can be re-written to be more efficient, but all my attempts have either failed, or not produced the same results.
Also, no indexes are defined on the table. Suggestions appreciated. I'm on Sybase iAnywhere 11 if that matters.