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

MPP-3927: Pre-fetch profile for domain address #5179

Merged
merged 3 commits into from
Nov 12, 2024

Conversation

jwhitlock
Copy link
Member

The API for domain address uses the subdomain on the Profile to construct the full domain address. Previously, this required 1 query to get all the domain addresses, then 2 queries per address to get the subdomain. So, a user with 100 domain addresses would use 201 queries to get their list of addresses when they visited the dashboard. This may contribute to some users getting a 30 second timeout when viewing the dashboard.

With this change, the user and profile query is done once, so a user needs 1 query if they have no domain addresses, and 3 total queries for any number of domain addresses.

The relay addresses API does not use user or profile data, so it continues to use 1 query for any number of addresses.

How to test:

The API for domain address uses the subdomain on the Profile to
construct the full domain address. Previously, this required 1 query to
get all the domain addresses, then 2 queries _per address_ to get the
subdomain. So, a user with 100 domain addresses would use 201 queries to
get their list of addresses when they visited the dashboard.

With this change, the user and profile query is done once, so a user
needs 1 query if they have no domain addresses, and 3 total queries for
any number of domain addresses.

The relay addresses API does not use user or profile data, so it
continues to use 1 query for any number of addresses.
@jwhitlock jwhitlock removed the request for review from groovecoder November 7, 2024 22:29
@jwhitlock jwhitlock removed their assignment Nov 7, 2024
@jwhitlock
Copy link
Member Author

Looking into the test failures

@jwhitlock jwhitlock marked this pull request as draft November 7, 2024 22:31
@jwhitlock jwhitlock assigned jwhitlock and unassigned groovecoder Nov 7, 2024
@jwhitlock jwhitlock marked this pull request as ready for review November 8, 2024 16:18
@jwhitlock
Copy link
Member Author

Figured it out. The sqlcommenter middleware was doubling the queries recorded for sqlite. After disabling it in the tests, the tests pass with both sqlite and psql.

Copy link
Member

@groovecoder groovecoder left a comment

Choose a reason for hiding this comment

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

praise: dang, nice investigation and fix! thanks for aligning the request IDs across all the services too.

api/tests/emails_views_tests.py Show resolved Hide resolved
Second query: {"sql": "SELECT id, ..."}A
"""

# The sqlcommenter middleware records queries twice for sqlite
Copy link
Member

Choose a reason for hiding this comment

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

suggestion (non-blocking): this comment is redundant after the doc-block above

Suggested change
# The sqlcommenter middleware records queries twice for sqlite
# The sqlcommenter middleware records queries twice for sqlite

@jwhitlock jwhitlock added this pull request to the merge queue Nov 12, 2024
Merged via the queue into main with commit a0d7ffd Nov 12, 2024
30 checks passed
@jwhitlock jwhitlock deleted the check-api-queries-mpp-3927 branch November 12, 2024 17:43
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