Skip to content

Slow display of surveys #5697

@clauded

Description

@clauded

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:

  1. Create a survey with multiple questions
  2. Fill in the survey (if possible hundreds of answers)
  3. Goto the page of the survey (either authenticated or not)
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions