Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- id INT UNSIGNED AUTO_INCREMENT NOT NULL -- make it `BIGINT` if expect > 4 billion
- PRIMARY KEY(shift, timestamp, id) -- In this order
- INDEX(id), -- for AUTO_INCREMENT
- INDEX(shift) -- DROP; it is now redundant with new PK
- INDEX(tag_id) -- get rid of this; it is redundant with the next two
- INDEX(tag_id, shift, timestamp) -- what query is this for?
- INDEX(tag_id, timestamp) -- what query is this for?
- CREATE TABLE h_new LIKE historical_data; -- copy schema
- ALTER TABLE h_new ... -- to get PK, better datatypes, indexes, etc.
- RENAME TABLE historical_data TO h_old,
- h_new TO historical_data; -- atomically swap
- then...
Add Comment
Please, Sign In to add comment