-
Notifications
You must be signed in to change notification settings - Fork 125
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
single sequence for all metrics sub tables #48
Conversation
Seems ok to me. |
Can you also drop all of the individual sequences? Also, since this PR doesn't change the insertion into the main table, I'm assuming that still works as well? |
@chessbyte thanks. I had thought this was merged already - will rebase and push again |
@kbrock Can you address #48 (comment) ? |
ugh. thanks @Fryguy
|
Before: there was a different sequence for each metrics_** table After: all use the same sequence. so you can insert into any table
Checked commit kbrock@130d14c with ruby 2.3.3, rubocop 0.47.1, and haml-lint 0.20.0 |
|
||
def down | ||
change_sequences("metrics", 0..23, true) | ||
change_sequences("metric_rollups", 1..12, true) |
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.
@kbrock I just realized that on the down migration I think you also have to update the nextval to the highest id in the table or you'll get duplicates.
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.
In the old code, we can not create a record in the old tables.
The sequences will overlap.
So we have never created a record there.
Yes we will reset the sequence back to 1. But since they haven't been used up until now, I think they are all 1 anyway.
And if they weren't, then that would be kinda bad - it would mean we have bad data in our metrics tables
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.
Ahhhh I see. The only other thing we might want to do is ensure we set the value to the "min value for the region" as opposed to 1. If that happens automatically, then we are good.
Before:
Every
metrics_**
table had a different sequence.So inserting directly into a subtable would result in overlapping
id
values.We currently insert into the base
metrics
table, so this is not a problem.After:
Every
metrics
subtable uses the same sequence.So inserting into any of the metrics tables will get a unique id.
Rollback does bring back to the previous value
This change allows us to insert directly into the subtable, which is 10x faster than inserting into the common parent table.
/cc @chrisarcand @Fryguy