use db to count