Add DB performance analysis tests and performance improvements.