Today I face a problem: If I select data using order by transaction_date, the result will be ordered by date (ascending by default) an row count may be more than 1. This is query that I’m use:
SELECT * FROM transaction ORDER BY transaction_date
But, cost (of I/O) of this query is too big.. this query execution will need very long time depend on how many data in table Transaction. I don’t want use this query, but I need the latest data transaction, I need first row only.
In DB2, we can simplify this matter, just modify query above to be like this:
SELECT * FROM transaction ORDER BY transaction_date FETCH FIRST ROW ONLY
Using this new query, cost of I/O will be small, and query execution will be so fast