Development #37868
Utiliser UNION ALL au lieu de UNION pour wcs_all_forms
0%
Description
UNION force un tri1 de l'union (pour déduplication), il n'est pas nécessaire.
1 https://hakibenita.com/sql-dos-and-donts#know-the-difference-between-union-and-union-all
Fichiers
Révisions associées
sql: use UNION ALL for wcs_all_forms (#37868)
Historique
Mis à jour par Benjamin Dauvergne il y a plus de 4 ans
- Description mis à jour (diff)
- Assigné à
Benjamin Dauvergnesupprimé
Mis à jour par Benjamin Dauvergne il y a plus de 4 ans
- Fichier 0001-formdef-sort-keys-in-export_to_json.patch 0001-formdef-sort-keys-in-export_to_json.patch ajouté
- Fichier 0002-sql-use-UNION-ALL-for-wcs_all_forms-37868.patch 0002-sql-use-UNION-ALL-for-wcs_all_forms-37868.patch ajouté
- Statut changé de Nouveau à Solution proposée
- Patch proposed changé de Non à Oui
Le premier commit n'est pas totalement gratuit, les tests ne passent pas chez moi à cause d'un non déterminisme dans assert_xml_import_export_works().
Le deuxième commit fait le changement UNION vers UNION ALL.
______________________________________________________________________________ test_file_field ______________________________________________________________________________ def test_file_field(): formdef = FormDef() formdef.name = 'foo' formdef.fields = [fields.FileField(type='file', id='1', document_type={ 'id': 'justificatif-de-domicile', 'fargo': True, 'mimetypes': ['application/pdf,application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'image/*'], })] > assert_xml_import_export_works(formdef, include_id=True) tests/test_formdef_import.py:303: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_formdef_import.py:44: in assert_xml_import_export_works assert_compare_formdef(formdef, formdef2, include_id=include_id) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ formdef1 = <FormDef 'foo' id:None>, formdef2 = <FormDef 'foo' id:None>, include_id = True def assert_compare_formdef(formdef1, formdef2, include_id=False): assert ET.tostring(export_to_indented_xml(formdef1, include_id=include_id)) == \ ET.tostring(export_to_indented_xml(formdef2, include_id=include_id)) > assert formdef1.export_to_json(include_id=include_id, indent=2) == \ formdef2.export_to_json(include_id=include_id, indent=2) E assert '{\n "name":... }\n ]\n}' == '{\n "name": ... }\n ]\n}' E { E "name": "foo", E "workflow": { E "name": "Default", E "id": "_default", E "functions": { E "_receiver": "Recipient" E }, E "statuses": [ E { E "id": "just_submitted", E "name": "Just Submitted", E "forced_endpoint": false, E "endpoint": false, E "waitpoint": false E }, E { E "id": "new", E "name": "New", E "forced_endpoint": false, E "endpoint": false, E "waitpoint": true E }, E { E "id": "rejected", E "name": "Rejected", E "forced_endpoint": false, E "endpoint": true, E "waitpoint": true E }, E { E "id": "accepted", E "name": "Accepted", E "forced_endpoint": false, E "endpoint": false, E "waitpoint": true E }, E { E "id": "finished", E "name": "Finished", E "forced_endpoint": false, E "endpoint": true, E "waitpoint": true E } E ], E "fields": [] E }, E "url_name": null, E "description": null, E "keywords": null, E "publication_date": null, E "expiration_date": null, E "internal_identifier": null, E "disabled_redirection": null, E "appearance_keywords": null, E "digest_template": null, E "discussion": false, E "detailed_emails": true, E "disabled": false, E "only_allow_one": false, E "enable_tracking_codes": false, E "confirmation": true, E "always_advertise": false, E "has_captcha": false, E "skip_from_360_view": false, E "max_field_id": 1, E "fields": [ E { E "type": "file", E "required": true, E "prefill": {}, E "document_type": { E + "fargo": true, E "id": "justificatif-de-domicile", E - "fargo": true, E "mimetypes": [ E "application/pdf,application/vnd.openxmlformats-officedocument.wordprocessingml.document", E "image/*" E ] E }, E "allow_portfolio_picking": false, E "automatic_image_resize": false, E "id": "1" E } E ] E } tests/test_formdef_import.py:38: AssertionError
Mis à jour par Benjamin Dauvergne il y a plus de 4 ans
- Fichier create_temp_view.sql create_temp_view.sql ajouté
Et pour justifier un peut tout ça, j'ai créé une vue temporaire wcs_all_forms_test (CREATE TEMP VIEW, ça ne restera pas) sur l'instance Nancy qui est une des plus grosses et fait un simple select count(*) from wcs_all_forms_test
(avec UNION ALL) puis un select count(*) from wcs_all_forms
(sans) :
Union all: Planning time: 42.727 ms Execution time: 2285.395 ms Union : Planning time: 42.776 ms Execution time: 3262.546 ms
On gagne une bonne seconde sur une requête un peu con je l'avoue, mais sur une simple pagination ça marche aussi :
wcs_demarches_nancy_fr=# select id from wcs_all_forms_test order by receipt_time desc limit 50; Temps : 2500,365 ms wcs_demarches_nancy_fr=# select id from wcs_all_forms order by receipt_time desc limit 50; Temps : 3428,498 ms
Mis à jour par Frédéric Péters il y a plus de 4 ans
- Statut changé de Solution proposée à Solution validée
Mis à jour par Frédéric Péters il y a plus de 4 ans
- Statut changé de Solution validée à Résolu (à déployer)
commit 74098a260806d818d066daeeb5fa36663b29eca1 Author: Benjamin Dauvergne <bdauvergne@entrouvert.com> Date: Thu Nov 21 23:06:23 2019 +0100 sql: use UNION ALL for wcs_all_forms (#37868) commit 1b33a1de18a9243eada662903c7e52cfdf23cf01 Author: Benjamin Dauvergne <bdauvergne@entrouvert.com> Date: Thu Nov 21 23:06:06 2019 +0100 formdef: sort keys in export_to_json() (~ #37868)
Mis à jour par Frédéric Péters il y a plus de 4 ans
- Statut changé de Résolu (à déployer) à Solution déployée
formdef: sort keys in export_to_json() (~ #37868)