Skip to content

[IMP] partner_internal_code: trigram index on internal_code behind a feature flag - #161

Open
fw-bot-adhoc wants to merge 1 commit into
ingadhoc:19.0from
adhoc-dev:19.0-18.0-t-79487-maq-11356-fw
Open

fw-bot-adhoc wants to merge 1 commit into
ingadhoc:19.0from
adhoc-dev:19.0-18.0-t-79487-maq-11356-fw

Conversation

@fw-bot-adhoc

Copy link
Copy Markdown

Tarea: https://www.adhoc.inc/odoo/project.task/79487

Qué cambia

Complemento de ingadhoc/miscellaneous#505 (base_ux). Cuando internal_code está en los campos de búsqueda de base_name_search_improved, cada pasada del módulo hace unaccent(internal_code) ILIKE '%texto%', y el campo solo tiene btree: recorre la tabla entera.

partner_internal_code crea desde init() un índice gin de trigramas en internal_code (res_partner__internal_code_trgm_index), con el mismo patrón que base_ux:

  • Nombre propio, al lado del btree del campo. Declarar index="trigram" haría que el registry borre el btree y lo recree como gin sin CONCURRENTLY; el btree sirve el = y el control de unicidad.
  • Mismo flag: solo se crea con saas_feature.partner_search_trigram_index prendido, en el próximo -u del módulo.
  • Sin pg_trgm o con unaccent no IMMUTABLE no se crea nada (log en info).

Medición

Copia de una base 18.0 con 272k contactos y internal_code como campo de búsqueda, con los índices de base_ux ya creados. name_search(limit=8):

Término Sin índice en internal_code Con índice
sin resultados 908 a 928 ms (4 consultas de ~215 ms en internal_code) 9 a 16 ms
dos palabras 239 ms 13 ms

Crear el índice: 2,4 s, 5,8 MB.

Forward-Port-Of: #160

…feature flag

- Create a gin trigram index on unaccent(internal_code) from init(), so
  ILIKE '%term%' on the field stops scanning the whole table (it is one of
  the smart search fields of base_name_search_improved)
- Use an own index name next to the btree of the field: declaring
  index="trigram" would make the registry drop the btree and rebuild it as
  gin without CONCURRENTLY, and the btree serves "=" and the unique check
- Only create it when the system parameter
  saas_feature.partner_search_trigram_index is on, the same flag as the
  base_ux partner search indexes; it is built on the next -u of the module
- Skip creation when pg_trgm is missing or unaccent is not IMMUTABLE
- Bump version to 18.0.1.1.0

Change note: Búsqueda de contactos por código interno más rápida en bases con muchos contactos (se habilita por base)

X-original-commit: 44d6928
@roboadhoc

Copy link
Copy Markdown

Pull request status dashboard

@fw-bot-adhoc

Copy link
Copy Markdown
Author

@maq-adhoc @az-adhoc cherrypicking of pull request #160 failed.

stdout:

Auto-merging partner_internal_code/__manifest__.py
CONFLICT (content): Merge conflict in partner_internal_code/__manifest__.py
Auto-merging partner_internal_code/models/res_partner.py
CONFLICT (content): Merge conflict in partner_internal_code/models/res_partner.py

Either perform the forward-port manually (and push to this branch, proceeding as usual) or close this PR (maybe?).

:shipit: you can use git-fw to re-do the forward-port for you locally.

⚠️ after resolving this conflict, you will need to merge it via @roboadhoc.

More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants