Database sharding

It’s recommended to create a database backup before working

sudo staffcop backup_db
  1. Enable sharding

sudo staffcop shard install

Command creates a copy of agent_event table, thats why it requires at least 2 time more free space on the disk then the current database occupies. Then it creates a number of tables for the last year: all the months starting from the 1 date, a month in advance, and a default table for all the events that don’t go into any of the created tables. Then you will be offered to delete the old database. You should agree only if you are sure that everything has worked correctly.

  1. Get the list of shards

sudo staffcop shard list

Will output all the tables, divided by month.

  1. Create a “cold” storage - for example, on a separate disk for creating an archive.

sudo staffcop shard cold /var/lib/staffcop/upload/coldbase
  1. “Freeze” a certain month

staffcop shard freeze agent_event_2018_03_01

The command freezes March of 2018, transferring it to the slow disk.

  1. Delete data for certain months

staffcop shard drop agent_event_2018_02_01

Command deletes data for February of 2018.