Describe the bug
When a survey has a lot of response (400 or more for example), it can take 15 seconds to display the survey page.
To Reproduce
Steps to reproduce the behavior:
- Create a survey with multiple questions
- Fill in the survey (if possible hundreds of answers)
- Goto the page of the survey (either authenticated or not)
- The survey will take a long time to display
Expected behavior
Response time should be irrelevant of the number of responses to the survey.
Screenshots
N/A
Stacktrace
If applicable, add the error stacktrace to help explain your problem.
Extra data (please complete the following information):
- Device: Desktop
- Device OS: All OS
- Browser: Any browser
- Decidim Version: 0.18.0
- Decidim installation: Ansible
Additional context
Running a debug while displaying the page, we can see a lot of requests to the server before displaying the page. It looks like all current answers are queried before displaying the page to answer the survey:
D, [2020-02-10T12:21:06.823281 #101275] DEBUG -- : [be64942f-dfd4-4e5a-8671-41ec91a35479] CACHE Decidim::Forms::Question Load (0.0ms) SELECT "decidim_forms_questions".* FROM "decidim_forms_questions" WHERE "decidim_forms_questions"."id" = $1 LIMIT $2 [["id", 61], ["LIMIT", 1]]
D, [2020-02-10T12:21:06.827444 #101275] DEBUG -- : [be64942f-dfd4-4e5a-8671-41ec91a35479] Decidim::Forms::AnswerChoice Load (2.1ms) SELECT "decidim_forms_answer_choices".* FROM "decidim_forms_answer_choices" WHERE "decidim_forms_answer_choices"."decidim_answer_id" = $1 [["decidim_answer_id", 2200]]
...
repeated hunderds of times
Describe the bug
When a survey has a lot of response (400 or more for example), it can take 15 seconds to display the survey page.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Response time should be irrelevant of the number of responses to the survey.
Screenshots
N/A
Stacktrace
If applicable, add the error stacktrace to help explain your problem.
Extra data (please complete the following information):
Additional context
Running a debug while displaying the page, we can see a lot of requests to the server before displaying the page. It looks like all current answers are queried before displaying the page to answer the survey:
...
repeated hunderds of times