$DB = DB->connect(...); my $size = sizeOfDB($DB); sub sizeOfDB { my $db = shift; my $size = 0; my $st = $db->prepare('show table status'); $st->execute; while (my $h = $st->fetchrow_hashref) { # other fields in %$h could be used, for example, # to limit the count to just certain tables. $size += $h->{Data_length} + $h->{Index_length}; } $st->finish; return $size; }