Denormalize event type for request and event logs#829
Closed
Conversation
25135c0 to
d0ebf37
Compare
ezekg
commented
May 1, 2024
d0ebf37 to
d78f333
Compare
ezekg
commented
May 1, 2024
ezekg
commented
May 1, 2024
db/migrate/20240501124926_add_event_type_event_to_request_logs.rb
Outdated
Show resolved
Hide resolved
ezekg
commented
May 1, 2024
db/migrate/20240501124919_add_event_type_event_to_event_logs.rb
Outdated
Show resolved
Hide resolved
d78f333 to
5dde815
Compare
Hamayoon931374
approved these changes
Jul 1, 2024
ezekg
commented
Jan 13, 2025
| has_environment | ||
| has_account | ||
|
|
||
| denormalizes :event, from: :event_type, prefix: :event_type |
Member
Author
There was a problem hiding this comment.
Should we be denormalizing event_type_id from event_log too? Would solve for the race condition touched on here.
ezekg
commented
Jan 13, 2025
| has_account | ||
|
|
||
| denormalizes :event, from: :event_type, prefix: :event_type | ||
| denormalizes :event_type_id, to: :request_log |
Member
Author
There was a problem hiding this comment.
Possible race condition here since there's no guarantee an event log will be inserted after a request log. Need to rethink this (and write appropriate tests).
ezekg
commented
Jan 13, 2025
|
|
||
| belongs_to :requestor, polymorphic: true, optional: true | ||
| belongs_to :resource, polymorphic: true, optional: true | ||
| belongs_to :event_type, optional: true |
Member
Author
|
Closing because this is outdated and denormalizing a string column onto every event log row is going to be super expensive, storage-wise. I'd rather look into using materialized views or something to improve performance here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 1 of 4. Improves performance for Dashboard metrics.
Prerequisites
Post deploy
Part 2 (in order of operations)
event_type_eventfromevent_typestoevent_logs.NOT NULLconstraint toevent_logs.event_type_event.event_logs.event_type_event.VACUUM ANALYZE event_logs.Part 3 (in order of operations)
event_type_idandevent_type_eventfromevent_logstorequest_logs.NOT NULLconstraints torequest_logs.event_type_idandrequest_logs.event_type_event.request_logs.event_type_idandrequest_logs.event_type_event.VACUUM ANALYZE request_logs.Part 4
EventLog.for_event_typeto use denormalizedevent_type_eventcolumn for strings.RequestLog.for_event_typeto use denormalizedevent_type_eventcolumn.