Implement batch fetching by primary key via SQL IN operator

If an entity's primary key is a single column and is a Java object
(not a primitive) we can easily override the get(Iterable<K>) so it
uses a SQL IN to fetch all requested rows in one query, rather than
making a round-trip per request.

This optimization works only for primary key queries, because I'm
being lazy and not implementing any other form.  It also only is
good on databases which don't suffer from high query plan costs.
For example on Oracle the per-statement optimization cost is high
and this IN query causes a different SQL statement to be created
for each unique number of keys requested.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2 files changed