Skip to content

Conversation

st0012
Copy link
Contributor

@st0012 st0012 commented Aug 15, 2019

Summary

(The current state of this PR is to demonstrate my idea of the solution. So I hope I can get some feedback about the design.)

This PR is for #36177. The issue is that eager loading helpers for ActionText contents doesn't work as expected. Users still get n+1 queries after using helper scope like

Message.with_rich_text_content_and_embeds

The root cause of this issue is that we use globalid to query attachment blobs, which means it can't gain any benefit from preloaded data.

(See more detailed explanation here)

So my solution is to preload those blobs and store them into a table. And before using globalid locator to do the search, we perform a` lookup in the table first. If it's found (which should be most of the cases) then we just return the records. Otherwise, we perform the search via globalid locator.

The root cause of this issue is that we use globalid to query attachment
blobs, which means it can't gain any benefit from preloaded data.

So my solution is to preload those blobs and store them into a table.
And before using globalid locator to do the search, we perform a lookup
in the table with the parsed id. If it's found (which should be most of
the cases) then we just return the records. Otherwise, we perform the
search via globalid locator.
@inopinatus
Copy link
Contributor

You're certainly further along than I am because you actually have some code.

However here's my 2c: I think sgid attachments have two design gotchas worth addressing: N+1, and key rotation. It's a pity because using them in Action Text in this fashion was otherwise pretty slick IMO.

As a result, in my head I was thinking of grafting in an optional configuration whereby Action Text references attachments via a UUID and a polymorphic join table instead.

@rails-bot
Copy link

rails-bot bot commented Jan 7, 2020

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Thank you for your contributions.

@rails-bot rails-bot bot added the stale label Jan 7, 2020
@rails-bot rails-bot bot closed this Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants