Extract common query to a constant.

Perf ref: https://gist.github.com/vipulnsward/8209749201dfdd678c97