Databases Reference
In-Depth Information
We can see that there are only two consistent gets to answer the query, with reduced I/O
operations. If we ask for both the MIN and MAX values of the field, as in the query in step 6,
the execution plan will be as follows:
You can see that the index is not used and we return to the full table scan of the CUSTOMERS
table, with 1459 consistent gets (and more I/O).
If we want both the values, it's better to split the query into two separate queries, as in the
following statement:
SELECT
MIN(CUST_CREDIT_LIMIT) AS MIN_VALUE,
0 AS MAX_VALUE
FROM CUSTOMERS
UNION ALL
SELECT
0,
MAX(CUST_CREDIT_LIMIT)
FROM CUSTOMERS;
 
Search WWH ::




Custom Search