Let's say I have a basic query like:
SELECT a, b, c FROM x WHERE y=[Z]
This query [Z]is a "variable" with various values โโentered into the query.
Now consider the situation when we want to make the same query with two different known values [Z], for example, Z1and Z2. We can make two separate requests:
SELECT a, b, c FROM x WHERE y=Z1
SELECT a, b, c FROM x WHERE y=Z2
Or maybe we can programmatically create another query, for example:
SELECT a, b, c FROM x WHERE y in (Z1, Z2)
Now we have only one query (1 <2), but query construction and decomposition of the result set are a little more complicated, because we no longer perform simple simple queries.
Questions:
- What is the name of this optimization? (Is it worth it?)
- How can this be implemented from a Java application?
- Do existing Java ORM technologies help?