Repository navigation
[16.0][FIX] pms_l10n_es: INE report, avoid OR subqueries in groups - #471
Merged
OCA-git-bot merged 1 commit intoNov 2, 2026
Merged
Conversation
The "persons" and "others" group domains were an OR between two conditions on the reservation. Each side became a subquery over the whole reservation table, which PostgreSQL cannot plan as a semi-join under an OR: on a large database the report took minutes. Classify the reservations of the property and period once in Python and filter both groups by reservation id. Same semantics: many2one paths already resolve with active_test=False, and a missing partner or channel counts as not company / not online. Add a test for the customer and channel groups of the XML.
DarioLodeiros
force-pushed
the
16.0-fix-pms_l10n_es-ine-persons-perf
branch
from
November 2, 2026 16:11
3227d73 to
83ec9dc
Compare
Member
Author
|
/ocabot merge patch |
Contributor
|
What a great day to merge this nice PR. Let's do it! |
Contributor
|
Congratulations, your PR was merged at d6252a6. Thanks a lot for contributing to OCA. ❤️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On a large multi-property database the INE report took between 2 and 3.5 minutes per month and hotel. Almost all of that time went into two queries: the occupancy and ADR of the "persons" group.
The "persons" and "others" group domains are an OR between two conditions on the reservation:
Each side becomes a
reservation_id IN (SELECT ... FROM pms_reservation ...)subquery over the whole reservation table. Under an OR, PostgreSQL cannot turn them into semi-joins. When the subquery result does not fit inwork_mem, it materializes it and scans it again for every candidate reservation line. The plan we captured read about 96M shared buffers for ~1,500 lines.This change classifies the reservations of the property and period once, in Python. The two groups then filter by
reservation_id in ids. The semantics are the same: many2one paths already resolve withactive_test=False, a missing partner/channel counts as "not company"/"not online", andis_company/is_on_lineNULL counts as false.Same database, one month, three properties:
A test now covers the customer and channel groups (persons, companies, internet, others), which had no coverage.
Not changed here (separate follow-up):
ine_calculate_occupancydivides by the INE-room nights of every property, not only the selected one. The percentages are normalized afterwards, so this only affects rounding, but on multi-property databases it costs precision.