server-tools icon indicating copy to clipboard operation
server-tools copied to clipboard

[14.0][FIX] attachment_unindex_content: Add WHERE clause to UPDATE query

Open Ricardoalso opened this issue 1 year ago • 5 comments

Adding the WHERE clause, the query will only update rows where index_content is not NULL, reducing the number of unnecessary updates. If most values are already NULL, the speed execution is significantly improved; less than an hour for my test-case with an ir_attachment table of 300 GB. I used a SQL pre-script in order to batch the updates (batches of 10k records) before installing this specific attachment_unindex_content module and it really improved the global installation time needed.

Ricardoalso avatar Aug 27 '24 07:08 Ricardoalso

Hi @luisg123v, @moylop260, @ebirbe, some modules you are maintaining are being modified, check this out!

OCA-git-bot avatar Aug 27 '24 07:08 OCA-git-bot

SGTM

Would be nice if you have any performance comparison to include.

Let's give a chance to @luisg123v or @moylop260 to review.

ebirbe avatar Aug 27 '24 10:08 ebirbe

SGTM

Would be nice if you have any performance comparison to include.

Let's give a chance to @luisg123v or @moylop260 to review.

Thanks @ebirbe, I updated my PR description for more clarity

Ricardoalso avatar Aug 27 '24 11:08 Ricardoalso

Just out of interest, what would ALTER TABLE DROP COLUMN ..., ALTER TABLE ADD COLUMN do for performance.

gdgellatly avatar Aug 29 '24 23:08 gdgellatly

Just out of interest, what would ALTER TABLE DROP COLUMN ..., ALTER TABLE ADD COLUMN do for performance.

It is radically faster indeed. But AFAIK any constraints would be lost and need to be re-added manually and any eventual column-level permissions would need to be reapplied. But in a "normal" use-case it should work as there are none of those linked to the index_content column

Ricardoalso avatar Aug 30 '24 06:08 Ricardoalso