Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Responses and History Section Performance #582

Merged
merged 3 commits into from
May 30, 2024

Conversation

johnyu95
Copy link
Contributor

@johnyu95 johnyu95 commented May 23, 2024

This PR improves the performance of the responses and history section loading on the Request page.

Responses section issues:

  • Previously we were doing a nested query to the Responses and CommunicationMethods tables which is time consuming. This was done to remove letters sent as part of a determination. Removing the CommunicationMethods part of the query would result in redundant responses (determination response and corresponding letter response) being displayed. Fixed by querying for all responses then looping through the list to remove determination letters post query.
  • For agency users we are displaying a response's corresponding event timestamp instead of using response.date_modified. Original issue referenced in this PR Bugfix/OP-1339: Fix Date Closed Calculation #354. However this requires a slow query to the events table. Reverting back to displaying response.date_modified for now. Responses are still ordered using date_modified and it is being used to display the timestamp for anonymous users.
  • For modals of Note responses we are displaying the user who created the note but this requires a slow query to the events table which negatively scales performance with the more notes you have. Commenting out that section for now until we find a faster solution. Possibly create an endpoint to load modal content only when a response row is clicked, instead of on page load.
  • Fixed a bug for modals of Note responses where the content would show for the first Note but all Notes after that would be missing content. This is because we were using duplicate javascript variable names causing Notes after the first to error out. Fixed by using generic jquery selectors instead of assigning them to variables.

History section issues:

  • The events table currently has 24 million rows of data and querying based on request_id is time consuming. Queries take 5 seconds or more to complete. Fixed by indexing the request_id column to speed up queries.
  • Indexes increase query speed at the cost of increasing the size of the database. Currently a database backup is 4.5 GB and the created index around 1.5 GB, database backup will start to approach 6 GB. Monitor for any other negative impacts.

@johnyu95 johnyu95 requested a review from zgary May 24, 2024 17:20
@johnyu95 johnyu95 changed the title Fix Responses Section Performance Fix Responses and History Section Performance May 24, 2024
Copy link
Contributor

@zgary zgary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

@johnyu95 johnyu95 merged commit f805e3a into main May 30, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants