dynamically create `and/or` query for mapstat instead of using `in`

MySQL still doesn't use indexes for such in/sub-queries