Skip to content

Instantly share code, notes, and snippets.

@e0da
Created February 20, 2019 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e0da/6794045857f0d3df37a31ad11ba027a2 to your computer and use it in GitHub Desktop.
Save e0da/6794045857f0d3df37a31ad11ba027a2 to your computer and use it in GitHub Desktop.
cur.execute(<<-'SQL'.gsub('%s', tablename))
INSERT INTO `%s`
SELECT cs.nodeid, dbs.name database, rels.name `table`,
reps.name `index`, sum(reads) reads,
sum(deletes+inserts+replaces) writes,
count(cs.replica) replicas
FROM system.`databases` AS dbs
JOIN system.`relations` AS rels USING (db)
JOIN system.`representations` AS reps
ON (reps.relation = rels.table)
JOIN system.`slices` AS s USING (representation)
JOIN system.`replicas` AS r USING (slice)
JOIN system.container_stats AS cs USING (replica)
GROUP BY nodeid, `database`, `table`, `index`
% tablename)
SQL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment