Guest User

Untitled

a guest
Oct 16th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. id INT UNSIGNED AUTO_INCREMENT NOT NULL -- make it `BIGINT` if expect > 4 billion
  2. PRIMARY KEY(shift, timestamp, id) -- In this order
  3. INDEX(id), -- for AUTO_INCREMENT
  4. INDEX(shift) -- DROP; it is now redundant with new PK
  5. INDEX(tag_id) -- get rid of this; it is redundant with the next two
  6. INDEX(tag_id, shift, timestamp) -- what query is this for?
  7. INDEX(tag_id, timestamp) -- what query is this for?
  8.  
  9. CREATE TABLE h_new LIKE historical_data; -- copy schema
  10. ALTER TABLE h_new ... -- to get PK, better datatypes, indexes, etc.
  11. RENAME TABLE historical_data TO h_old,
  12. h_new TO historical_data; -- atomically swap
  13. then...
Add Comment
Please, Sign In to add comment