optimize photo/query