This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tables <- SQLQuery(" | |
select TABLE_NAME as table_name | |
from cs_reporting.information_schema.tables | |
where table_type = 'BASE TABLE'") | |
sizes <- rbindlist(lapply(tables$table_name, function(x) SQLQuery(paste0("sp_spaceused [", x, "]")))) | |
StripKB <- function(x) as.integer(str_replace_all(x, ' KB', '')) | |
sizes[, reserved := StripKB(reserved)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(digest) | |
LoadRDataIfExists <- function(fn) { | |
# Calls _fn_ and caches the result on disk, unless the cache already exists | |
# | |
# _fn_ should be a function with signature _fn(filename, ...)_ | |
# If cache file exists and is recent, load data from it. | |
# Otherwise call the original function. | |
function (filename, ...) { | |
param.hash = digest(c(fn, list(...))) # Cache file names depends on params/fn def |
NewerOlder