Skip to content

Conversation

ClearlyClaire
Copy link
Contributor

The CTE used CROSS JOIN instead of a JOIN LATERAL, meaning that the notifications query could not use the (single-item) working table for quick filtering, and had to filter and limit a posteriori, causing a lot of extra work.

Unfortunately, it does not seem ActiveRecord exposes LATERAL, so we have to work around with arel. Using the FROM foo, LATERAL (SELECT …) allows keeping arel usage to a minimal.

@ClearlyClaire ClearlyClaire added the performance Runtime performance label Jul 24, 2024
@ClearlyClaire ClearlyClaire force-pushed the fixes/cte-performance branch from 1b10a91 to 79cb5f2 Compare July 24, 2024 14:22
@ClearlyClaire ClearlyClaire added the build-image Build a container image for this PR label Jul 24, 2024
@ClearlyClaire ClearlyClaire added this pull request to the merge queue Jul 24, 2024
Merged via the queue into main with commit 3a49687 Jul 24, 2024
32 checks passed
@ClearlyClaire ClearlyClaire deleted the fixes/cte-performance branch July 24, 2024 19:09
justinwritescode pushed a commit to justinwritescode/mastodon that referenced this pull request Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build-image Build a container image for this PR performance Runtime performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants