Skip to content

Conversation

@cawo-odoo
Copy link
Contributor

[IMP] orm: iter_browse accept generator or query as ids

This allows the caller to be memory efficient on huge numbers of ids, allowing for even more millions of records to be browsed.

[IMP] orm: iter_browse.create() accept generator or query as values

Done to be able to create millions of records memory-efficiently.

@cawo-odoo cawo-odoo requested review from a team and KangOl November 10, 2025 13:21
@robodoo
Copy link
Contributor

robodoo commented Nov 10, 2025

Pull request status dashboard

@cawo-odoo cawo-odoo force-pushed the master-imp_iter_browse_save_memory-cawo branch 2 times, most recently from 01d0fba to 16a2e55 Compare November 12, 2025 08:28
@KangOl
Copy link
Contributor

KangOl commented Nov 13, 2025

upgradeci retry with always only account

@cawo-odoo cawo-odoo requested a review from aj-fuentes November 24, 2025 12:02
@cawo-odoo cawo-odoo force-pushed the master-imp_iter_browse_save_memory-cawo branch 2 times, most recently from d3e1776 to ebf911e Compare November 25, 2025 14:31
@cawo-odoo
Copy link
Contributor Author

rebased on #355 to also make use of query_ids() here

@cawo-odoo cawo-odoo force-pushed the master-imp_iter_browse_save_memory-cawo branch 5 times, most recently from cdfe851 to 161bdfb Compare December 2, 2025 12:53
This is mainly the code that has been recently added to `orm.recompute_fields`,
here we're making it re-usasble.
This code in recompute_fields has been made re-usable in a new util
pg.query_ids. Use that.
```
Traceback (most recent call last):
[...]
  File "/tmp/tmpipxrg2eq/migrations/util/models.py", line 563, in merge_model
    remove_model(cr, source, drop_table=drop_table, ignore_m2m=ignore_m2m)
  File "/tmp/tmpipxrg2eq/migrations/util/models.py", line 138, in remove_model
    it = chunks([id for (id,) in cr.fetchall()], chunk_size, fmt=tuple)
MemoryError
```

Some IR tables can be large. Avoid `cr.fetchall()` when getting ids by use of
pg.query_ids()
This allows the caller to be memory efficient on huge numbers of ids, allowing
for even more millions of records to be browsed.
Done to be able to create millions of records memory-efficiently.
@cawo-odoo cawo-odoo force-pushed the master-imp_iter_browse_save_memory-cawo branch from 161bdfb to ad0d9e5 Compare December 5, 2025 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants