fix(Migration): Don't use subquery - #1360
Conversation
ad00d9c to
23ca9ca
Compare
There was a problem hiding this comment.
Pull Request Overview
This migration removes a subquery from a database update operation by replacing it with separate query execution and parameter binding. The change eliminates the use of createFunction() with a nested SQL query in favor of fetching IDs first and then using them as parameters.
- Replaced subquery pattern with parameter-based approach for better database compatibility
- Added explicit result handling with cursor management
- Introduced PDO import for fetch operations
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| $query->update('recognize_face_detections') | ||
| ->set('face_vector', 'vector') | ||
| ->where($query->expr()->in('id', $query->createFunction('(' . $select->getSQL() .')'))); | ||
| ->where($query->expr()->in('id', $query->createParameter('ids'))); |
There was a problem hiding this comment.
Shouldn't you be able to update all with a single query?
| ->where($query->expr()->in('id', $query->createParameter('ids'))); | |
| ->where($select->expr()->isNull('face_vector')); | |
| $query->executeStatement() |
if you are not doing any data manipulation that should work just fine.
No previous select or anything needed.
There was a problem hiding this comment.
Shouldn't you be able to update all with a single query?
Doesn't seem work for large tables, sadly. See #1357
There was a problem hiding this comment.
Put a transaction around it?
There was a problem hiding this comment.
But anyway, should also be good like this, but it will run much longer.
But also in this version a transaction should speed up the update I think
There was a problem hiding this comment.
Mh, the issue in #1357 is due to a long running transaction, wouldn't wrapping the current state in this branch in a transaction introduce the issue of a long running transaction again?
There was a problem hiding this comment.
You can close the transaction after each chunk.
THe idea is to reduce the number of writes
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
23ca9ca to
6852ac1
Compare
No description provided.