Project

General

Profile

Development #57635

Sur un appel à /backoffice/management/contacter-le-departement/*/live des appels à FormPage.set_default_view() sont faits qui ne semblent pas tous nécessaires voir redondant

Added by Benjamin Dauvergne over 1 year ago. Updated over 1 year ago.

Status:
Nouveau
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
06 October 2021
Due date:
% Done:

0%

Estimated time:
Patch proposed:
No
Planning:
No

Description

oct. 05 18:30:55 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/quixote/directory.py", line 88, in _q_traverse
oct. 05 18:30:55 wcs uwsgi[31963]:     return obj._q_traverse(path)
oct. 05 18:30:55 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/backoffice/management.py", line 153, in _q_traverse
oct. 05 18:30:55 wcs uwsgi[31963]:     return super()._q_traverse(path)
oct. 05 18:30:55 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/quixote/directory.py", line 82, in _q_traverse
oct. 05 18:30:55 wcs uwsgi[31963]:     obj = self._q_lookup(component)
oct. 05 18:30:55 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/backoffice/management.py", line 768, in _q_lookup
oct. 05 18:30:55 wcs uwsgi[31963]:     return FormPage(component)
oct. 05 18:30:55 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/backoffice/management.py", line 809, in __init__
oct. 05 18:30:55 wcs uwsgi[31963]:     self.set_default_view()
oct. 05 18:30:55 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/backoffice/management.py", line 814, in set_default_view
oct. 05 18:30:55 wcs uwsgi[31963]:     custom_views = list(self.get_custom_views())
oct. 05 18:30:55 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/backoffice/management.py", line 855, in get_custom_views
oct. 05 18:30:55 wcs uwsgi[31963]:     for view in get_publisher().custom_view_class.select(clause=criterias):
oct. 05 18:30:55 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/sql.py", line 505, in f
oct. 05 18:30:55 wcs uwsgi[31963]:     return func(*args, **kwargs)
oct. 05 18:30:55 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/sql.py", line 1716, in select
oct. 05 18:30:55 wcs uwsgi[31963]:     return list(objects)
oct. 05 18:30:55 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/sql.py", line 1649, in select_iterator
oct. 05 18:30:55 wcs uwsgi[31963]:     traceback.print_stack(limit=10)

oct. 05 18:30:56 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/quixote/directory.py", line 116, in _q_traverse
oct. 05 18:30:56 wcs uwsgi[31963]:     return super(AccessControlled, self)._q_traverse(path)
oct. 05 18:30:56 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/quixote/directory.py", line 88, in _q_traverse
oct. 05 18:30:56 wcs uwsgi[31963]:     return obj._q_traverse(path)
oct. 05 18:30:56 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/backoffice/management.py", line 153, in _q_traverse
oct. 05 18:30:56 wcs uwsgi[31963]:     return super()._q_traverse(path)
oct. 05 18:30:56 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/quixote/directory.py", line 88, in _q_traverse
oct. 05 18:30:56 wcs uwsgi[31963]:     return obj._q_traverse(path)
oct. 05 18:30:56 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/quixote/directory.py", line 82, in _q_traverse
oct. 05 18:30:56 wcs uwsgi[31963]:     obj = self._q_lookup(component)
oct. 05 18:30:56 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/backoffice/management.py", line 2429, in _q_lookup
oct. 05 18:30:56 wcs uwsgi[31963]:     for view in self.get_custom_views():
oct. 05 18:30:56 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/backoffice/management.py", line 855, in get_custom_views
oct. 05 18:30:56 wcs uwsgi[31963]:     for view in get_publisher().custom_view_class.select(clause=criterias):
oct. 05 18:30:56 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/sql.py", line 505, in f
oct. 05 18:30:56 wcs uwsgi[31963]:     return func(*args, **kwargs)
oct. 05 18:30:56 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/sql.py", line 1716, in select
oct. 05 18:30:56 wcs uwsgi[31963]:     return list(objects)
oct. 05 18:30:56 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/sql.py", line 1649, in select_iterator
oct. 05 18:30:56 wcs uwsgi[31963]:     traceback.print_stack(limit=10)

oct. 05 18:30:56 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/data_sources.py", line 267, in get_structured_items
oct. 05 18:30:56 wcs uwsgi[31963]:     items = _get_structured_items(data_source, mode=mode)
oct. 05 18:30:56 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/data_sources.py", line 280, in _get_structured_items
oct. 05 18:30:56 wcs uwsgi[31963]:     return CardDef.get_data_source_items(data_source['type'])
oct. 05 18:30:56 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/carddef.py", line 207, in get_data_source_items
oct. 05 18:30:56 wcs uwsgi[31963]:     criterias.extend(custom_view.get_criterias(formdef=carddef))
oct. 05 18:30:56 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/custom_views.py", line 161, in get_criterias
oct. 05 18:30:56 wcs uwsgi[31963]:     form_page = FormPage(formdef=formdef, view=self, update_breadcrumbs=False)
oct. 05 18:30:56 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/backoffice/management.py", line 809, in __init__
oct. 05 18:30:56 wcs uwsgi[31963]:     self.set_default_view()
oct. 05 18:30:56 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/backoffice/management.py", line 814, in set_default_view
oct. 05 18:30:56 wcs uwsgi[31963]:     custom_views = list(self.get_custom_views())
oct. 05 18:30:56 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/backoffice/management.py", line 855, in get_custom_views
oct. 05 18:30:56 wcs uwsgi[31963]:     for view in get_publisher().custom_view_class.select(clause=criterias):
oct. 05 18:30:56 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/sql.py", line 505, in f
oct. 05 18:30:56 wcs uwsgi[31963]:     return func(*args, **kwargs)
oct. 05 18:30:56 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/sql.py", line 1716, in select
oct. 05 18:30:56 wcs uwsgi[31963]:     return list(objects)
oct. 05 18:30:56 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/sql.py", line 1649, in select_iterator
oct. 05 18:30:56 wcs uwsgi[31963]:     traceback.print_stack(limit=10)

oct. 05 18:30:57 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/formdef.py", line 779, in set_live_condition_sources
oct. 05 18:30:57 wcs uwsgi[31963]:     varnames = data_source.get_referenced_varnames(formdef=self)
oct. 05 18:30:57 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/data_sources.py", line 806, in get_referenced_varnames
oct. 05 18:30:57 wcs uwsgi[31963]:     return CardDef.get_data_source_referenced_varnames(self.type, formdef=formdef)
oct. 05 18:30:57 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/carddef.py", line 280, in get_data_source_referenced_varnames
oct. 05 18:30:57 wcs uwsgi[31963]:     for criteria in custom_view.get_criterias(formdef=carddef):
oct. 05 18:30:57 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/custom_views.py", line 161, in get_criterias
oct. 05 18:30:57 wcs uwsgi[31963]:     form_page = FormPage(formdef=formdef, view=self, update_breadcrumbs=False)
oct. 05 18:30:57 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/backoffice/management.py", line 809, in __init__
oct. 05 18:30:57 wcs uwsgi[31963]:     self.set_default_view()
oct. 05 18:30:57 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/backoffice/management.py", line 814, in set_default_view
oct. 05 18:30:57 wcs uwsgi[31963]:     custom_views = list(self.get_custom_views())
oct. 05 18:30:57 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/backoffice/management.py", line 855, in get_custom_views
oct. 05 18:30:57 wcs uwsgi[31963]:     for view in get_publisher().custom_view_class.select(clause=criterias):
oct. 05 18:30:57 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/sql.py", line 505, in f
oct. 05 18:30:57 wcs uwsgi[31963]:     return func(*args, **kwargs)
oct. 05 18:30:57 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/sql.py", line 1716, in select
oct. 05 18:30:57 wcs uwsgi[31963]:     return list(objects)
oct. 05 18:30:57 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/sql.py", line 1649, in select_iterator
oct. 05 18:30:57 wcs uwsgi[31963]:     traceback.print_stack(limit=10)

oct. 05 18:30:57 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/data_sources.py", line 267, in get_structured_items
oct. 05 18:30:57 wcs uwsgi[31963]:     items = _get_structured_items(data_source, mode=mode)
oct. 05 18:30:57 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/data_sources.py", line 280, in _get_structured_items
oct. 05 18:30:57 wcs uwsgi[31963]:     return CardDef.get_data_source_items(data_source['type'])
oct. 05 18:30:57 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/carddef.py", line 207, in get_data_source_items
oct. 05 18:30:57 wcs uwsgi[31963]:     criterias.extend(custom_view.get_criterias(formdef=carddef))
oct. 05 18:30:57 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/custom_views.py", line 161, in get_criterias
oct. 05 18:30:57 wcs uwsgi[31963]:     form_page = FormPage(formdef=formdef, view=self, update_breadcrumbs=False)
oct. 05 18:30:57 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/backoffice/management.py", line 809, in __init__
oct. 05 18:30:57 wcs uwsgi[31963]:     self.set_default_view()
oct. 05 18:30:57 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/backoffice/management.py", line 814, in set_default_view
oct. 05 18:30:57 wcs uwsgi[31963]:     custom_views = list(self.get_custom_views())
oct. 05 18:30:57 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/backoffice/management.py", line 855, in get_custom_views
oct. 05 18:30:57 wcs uwsgi[31963]:     for view in get_publisher().custom_view_class.select(clause=criterias):
oct. 05 18:30:57 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/sql.py", line 505, in f
oct. 05 18:30:57 wcs uwsgi[31963]:     return func(*args, **kwargs)
oct. 05 18:30:57 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/sql.py", line 1716, in select
oct. 05 18:30:57 wcs uwsgi[31963]:     return list(objects)
oct. 05 18:30:57 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/sql.py", line 1649, in select_iterator
oct. 05 18:30:57 wcs uwsgi[31963]:     traceback.print_stack(limit=10)

oct. 05 18:30:58 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/formdef.py", line 779, in set_live_condition_sources
oct. 05 18:30:58 wcs uwsgi[31963]:     varnames = data_source.get_referenced_varnames(formdef=self)
oct. 05 18:30:58 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/data_sources.py", line 806, in get_referenced_varnames
oct. 05 18:30:58 wcs uwsgi[31963]:     return CardDef.get_data_source_referenced_varnames(self.type, formdef=formdef)
oct. 05 18:30:58 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/carddef.py", line 280, in get_data_source_referenced_varnames
oct. 05 18:30:58 wcs uwsgi[31963]:     for criteria in custom_view.get_criterias(formdef=carddef):
oct. 05 18:30:58 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/custom_views.py", line 161, in get_criterias
oct. 05 18:30:58 wcs uwsgi[31963]:     form_page = FormPage(formdef=formdef, view=self, update_breadcrumbs=False)
oct. 05 18:30:58 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/backoffice/management.py", line 809, in __init__
oct. 05 18:30:58 wcs uwsgi[31963]:     self.set_default_view()
oct. 05 18:30:58 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/backoffice/management.py", line 814, in set_default_view
oct. 05 18:30:58 wcs uwsgi[31963]:     custom_views = list(self.get_custom_views())
oct. 05 18:30:58 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/backoffice/management.py", line 855, in get_custom_views
oct. 05 18:30:58 wcs uwsgi[31963]:     for view in get_publisher().custom_view_class.select(clause=criterias):
oct. 05 18:30:58 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/sql.py", line 505, in f
oct. 05 18:30:58 wcs uwsgi[31963]:     return func(*args, **kwargs)
oct. 05 18:30:58 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/sql.py", line 1716, in select
oct. 05 18:30:58 wcs uwsgi[31963]:     return list(objects)
oct. 05 18:30:58 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/sql.py", line 1649, in select_iterator
oct. 05 18:30:58 wcs uwsgi[31963]:     traceback.print_stack(limit=10)

oct. 05 18:30:58 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/forms/common.py", line 761, in live_process_fields
oct. 05 18:30:58 wcs uwsgi[31963]:     varnames = data_source.get_referenced_varnames(field.formdef)
oct. 05 18:30:58 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/data_sources.py", line 806, in get_referenced_varnames
oct. 05 18:30:58 wcs uwsgi[31963]:     return CardDef.get_data_source_referenced_varnames(self.type, formdef=formdef)
oct. 05 18:30:58 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/carddef.py", line 280, in get_data_source_referenced_varnames
oct. 05 18:30:58 wcs uwsgi[31963]:     for criteria in custom_view.get_criterias(formdef=carddef):
oct. 05 18:30:58 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/custom_views.py", line 161, in get_criterias
oct. 05 18:30:58 wcs uwsgi[31963]:     form_page = FormPage(formdef=formdef, view=self, update_breadcrumbs=False)
oct. 05 18:30:58 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/backoffice/management.py", line 809, in __init__
oct. 05 18:30:58 wcs uwsgi[31963]:     self.set_default_view()
oct. 05 18:30:58 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/backoffice/management.py", line 814, in set_default_view
oct. 05 18:30:58 wcs uwsgi[31963]:     custom_views = list(self.get_custom_views())
oct. 05 18:30:58 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/backoffice/management.py", line 855, in get_custom_views
oct. 05 18:30:58 wcs uwsgi[31963]:     for view in get_publisher().custom_view_class.select(clause=criterias):
oct. 05 18:30:58 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/sql.py", line 505, in f
oct. 05 18:30:58 wcs uwsgi[31963]:     return func(*args, **kwargs)
oct. 05 18:30:58 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/sql.py", line 1716, in select
oct. 05 18:30:58 wcs uwsgi[31963]:     return list(objects)
oct. 05 18:30:58 wcs uwsgi[31963]:   File "/usr/lib/python3/dist-packages/wcs/sql.py", line 1649, in select_iterator
oct. 05 18:30:58 wcs uwsgi[31963]:     traceback.print_stack(limit=10)

Pour les appels venant de _q_loopkup ou set_default_view, je pense qu'ils sont inutiles. Pour les appels venant de get_data_source_referenced_varnames/get_data_source_items on doit pouvoir faire du cache sur la requête.

Je comprends bien que ce ne sont pas les vues des mêmes objets qui sont appelées ici, mais on doit pouvoir s'en sortir en récupérant la totalité des vues de l'instance pour la durée d'une requête puisque c'est de toute façon déjà ce qu'on fait presque, sur une instance assez grosse comme toodego il y a 290 vues (dont 108 sans utilisateur, en visibilité ou datasource), sur montoulouse 627, (dont 121 sans utilisateur ou en visibilité any ou datasource).

Une log plus complet des SELECT sur custom_views pour un appel à une vue live (j'ai viré le nom des colonnes et le bruit en début de ligne), 12 requêtes pour 25 vues dans la table custom_views :

2021-10-06 11:15:40.424  SELECT ... FROM custom_views 
2021-10-06 11:15:40.439  SELECT ... FROM custom_views 
2021-10-06 11:15:40.558  SELECT ... FROM custom_views WHERE formdef_type = 'carddef' AND visibility = 'datasource' AND slug = 'filtre-par-dispositif-message_var_dispositif' AND formdef_id = '2' 
2021-10-06 11:15:40.572  SELECT ... FROM custom_views 
2021-10-06 11:15:40.686  SELECT ... FROM custom_views WHERE formdef_type = 'carddef' AND visibility = 'datasource' AND slug = 'filtre-par-dispositif-message_var_dispositif' AND formdef_id = '2' 
2021-10-06 11:15:40.700  SELECT ... FROM custom_views 
2021-10-06 11:15:40.941  SELECT ... FROM custom_views WHERE formdef_type = 'carddef' AND visibility = 'datasource' AND slug = 'filtre-par-dispositif-message_var_dispositif' AND formdef_id = '2' 
2021-10-06 11:15:40.955  SELECT ... FROM custom_views 
2021-10-06 11:15:41.067  SELECT ... FROM custom_views WHERE formdef_type = 'carddef' AND visibility = 'datasource' AND slug = 'filtre-par-dispositif-message_var_dispositif' AND formdef_id = '2' 
2021-10-06 11:15:41.081  SELECT ... FROM custom_views 
2021-10-06 11:15:41.202  SELECT ... FROM custom_views WHERE formdef_type = 'carddef' AND visibility = 'datasource' AND slug = 'filtre-par-dispositif-message_var_dispositif' AND formdef_id = '2' 
2021-10-06 11:15:41.217  SELECT ... FROM custom_views 


Related issues

Related to w.c.s. - Development #57623: sql: ne pas itérer ligne par ligne sur un SqlKlass.select(iterator=False)Rejeté05 October 2021

Actions

History

#3

Updated by Benjamin Dauvergne over 1 year ago

  • Related to Development #57623: sql: ne pas itérer ligne par ligne sur un SqlKlass.select(iterator=False) added

Also available in: Atom PDF