update to use custom query. Was timing out on very large databases.