-
Notifications
You must be signed in to change notification settings - Fork 86
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
Add helper method for decoding deleted record #1547
base: main
Are you sure you want to change the base?
Conversation
While working on DeletedRecord, we frequently need to find the record from its ubid. This commit adds a helper method for that.
4e3c633
to
17f0af1
Compare
UBID.decode(*) | ||
end | ||
|
||
def udec_deleted(ubid) | ||
DeletedRecord.where(Sequel.pg_json(:model_values)["name"] => Sequel.pg_jsonb_wrap(UBID.parse(ubid).to_uuid)).first | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about adding it to the udec
as a second option?
Probably we will run udec
first and it will return nil
, then we will run udec_deleted
UBID.decode(*) | |
end | |
def udec_deleted(ubid) | |
DeletedRecord.where(Sequel.pg_json(:model_values)["name"] => Sequel.pg_jsonb_wrap(UBID.parse(ubid).to_uuid)).first | |
end | |
UBID.decode(*) || DeletedRecord.where(Sequel.pg_json(:model_values)["name"] => Sequel.pg_jsonb_wrap(UBID.parse(ubid).to_uuid)).first | |
end |
@@ -17,6 +19,10 @@ def udec(*) | |||
UBID.decode(*) | |||
end | |||
|
|||
def udec_deleted(ubid) | |||
DeletedRecord.where(Sequel.pg_json(:model_values)["name"] => Sequel.pg_jsonb_wrap(UBID.parse(ubid).to_uuid)).first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we must add a gin index for this field. Simply querying deleted records in production is almost unbearable at this point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's also using almost all our space. Should we consider partitioning as well? How often are we digging in the ancient past? Not often, right?
GIN is perhaps the first thing to try, though the idea of a GIN over all (ever growing) history that has to get updated with every deletion makes me a little bit suspenseful. Just a bit.
@@ -17,6 +19,10 @@ def udec(*) | |||
UBID.decode(*) | |||
end | |||
|
|||
def udec_deleted(ubid) | |||
DeletedRecord.where(Sequel.pg_json(:model_values)["name"] => Sequel.pg_jsonb_wrap(UBID.parse(ubid).to_uuid)).first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we filter by id
instead of name
?
DeletedRecord.where(Sequel.pg_json(:model_values)["name"] => Sequel.pg_jsonb_wrap(UBID.parse(ubid).to_uuid)).first | |
DeletedRecord.where(Sequel.pg_json(:model_values)["id"] => Sequel.pg_jsonb_wrap(UBID.parse(ubid).to_uuid)).first |
While working on DeletedRecord, we frequently need to find the record from its ubid. This commit adds a helper method for that.