Skip to content

Instantly share code, notes, and snippets.

@benclark
Created October 29, 2012 17:12
Show Gist options
  • Save benclark/3974958 to your computer and use it in GitHub Desktop.
Save benclark/3974958 to your computer and use it in GitHub Desktop.
SQL snippet for estimating Drupal cache table sizes
-- Use this query when preparing to move cache tables into memcache bins
-- to estimate how big the bins should be (or how many will be necessary).
SELECT count(*) tables,
concat(round(sum(data_length)/(1024*1024),2),'M') data,
concat(round(sum(index_length)/(1024*1024),2),'M') idx,
concat(round(sum(data_length+index_length)/(1024*1024),2),'M') total_size
FROM information_schema.TABLES
WHERE table_schema LIKE '<<DRUPAL DATABASE NAME>>'
AND table_name like "cache%"
-- Exclude any cache tables you know won't be in memcache:
AND table_name NOT IN ('cache_form', 'cache_page');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment