FIX: statistics and encoding memory use when using very large databases