Add support to query by array of ids.

I've got a use case in drupal that this will help speed up a lot.