-
Notifications
You must be signed in to change notification settings - Fork 81
[IMP] pg,orm,models: query ids server side #355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[IMP] pg,orm,models: query ids server side #355
Conversation
568311e to
ac8c6d0
Compare
ac8c6d0 to
ffc872a
Compare
|
upgradeci retry with always only crm hr |
6aa7709 to
543204d
Compare
|
so, this avoids the memoryerror in upg-3307099 just fine |
aj-fuentes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could we follow the plan of "providing an object that would iterate ids and do the cleanup as early as possible". The cleanup would happen at iteration finished, __exit__, or __del__. Whatever happens first.
Technically:
- The class is primarily an iterator, once exhausted it will do all the cleanup.
- We guard against double iteration. (this pattern already exists in the utils)
- We double down the cleanup at
__del__just in case. - We triple down the cleanup at
__exit__to leverage the context manager semantic. We don't need to__enter__into_ncr. Current dummy__enter__returningselfis just fine.
Feel free to improve the stub suggestions below if you agree.
|
I pushed a version inspired by your suggestions, but I didn't use them verbatim. Please resolve conversations when you feel they have been addressed. 2 explanations up-front:
|
8017ffb to
3b42f99
Compare
610edfa to
6f069fb
Compare
fbe3bc3 to
76ae21e
Compare
76ae21e to
a11d862
Compare
1d65991 to
894c027
Compare
aj-fuentes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to post this yesterday.
Some documentation nits.
24afb9b to
af35535
Compare
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()
af35535 to
30020ce
Compare

[ADD] pg.query_ids: query large numbers of ids memory-safely
This is mainly the code that has been recently added to
orm.recompute_fields, here we're making it re-usasble.[IMP] orm.recompute_fields: use new pg.query_ids
This code in recompute_fields has been made re-usable in a new util
pg.query_ids. Use that.[FIX] models.remove_model: MemoryError