[FIX] mail: lower RAM usage of mail.message().search(limit=None)
[FIX] mail: lower RAM usage of mail.message().search(limit=None)

On an instance with 4 million messages, opening Settings > Technical >
Messages could increase residual memory usage in a given situation usage
by:

- 1.5 GB for odoo
- 3 GB for postgresql (a part might just be cache depending on config)

With this change breaking the request in several ones, increase is:

- 0.5 GB for odoo (for the millions of ids in dictionaries and list)
- 0.1 GB for postgresql

opw-2232065
closes #49689

closes odoo/odoo#50079

X-original-commit: 04e5b9f397e7fc752e9910c58eea589420b83a63
Signed-off-by: Nicolas Lempereur (nle) <2907e499a003d1c3ab7944c0a40c6df46e3e3c2f@odoo.com>

ygol/odoo,ygol/odoo,ygol/odoo,ygol/odoo,ygol/odoo,ygol/odoo,ygol/odoo