db: add counting feature.