The IN
operator in GQL is actually synthesized by application-level Python code as a loop doing a series of =
fetches and concatenating them -- it's not really part of the underlying store's capabilities and so is unfortunately subject to some limitations (and its performance is never particularly good). I'm not sure it was a great design decision to include it in the Python API (I believe it was not duplicated in the Java API), but, there you are. (Btw, the !=
operator has similar issues, too).
I'm not sure why in particular this should interfere with your intended usage, but I suspect it's due to the "query" object being an instance of datastore.MultiQuery rather than plain datastore.Query -- what happens if you do in your own application-level Python code what the GAE-supplied application level Python code normally does? See in your SDK sources file google/appengine/api/datastore.py, specifically the MultiQuery class -- in the end it boils down to doing all the separate queries and merging their results (in sorted order, if required, but that doesn't seem to be the case here).