Analysis and optimization of active databases