let the database do the counting