-
- Downloads
[FIX] fields: use `SAVEPOINT` when really creating the index
`update_db_index` is meant
to skip the creation of the index if it fails.
It therefore uses `with cr.savepoint()` for that purpose
But, before this revision, it surrounds `create_index`,
in which the index creation is skipped if it already exists.
Meaning, if the index already exists,
a savepoint was created for nothing.
Creating a savepoint has a cost.
Therefore, avoiding to create one when it's not necessary
is better for the performances.
In addition, during an installation / upgrades,
a lot of index are attempted to be created,
and the performance of postgresql are degraded
when there are more than 64 savepoints within the same transaction,
which could easily happen when installing/updating a module,
while attempting to create all its indexes (despite they already existed).
Moving only the `with cr.savepoint`, without moving the `try..except`
will have no impact on the API. It's still the role
of the method calling `create_index` to catch the exception
if it wants to.
Besides, for the methods which are calling `create_index`
without a `try..except` block, the transaction will still
be rollbacked, as it's the case for any uncatched exception
in Odoo.
There is therefore no downside to move `cr.savepoint` into `create_index`.
closes odoo/odoo#71565
Signed-off-by:
Denis Ledoux (dle) <dle@odoo.com>
Loading
Please register or sign in to comment