Db: improved performance and reduced memory usage