Quantcast
Channel: IBM Mainframe Computers Forums
Viewing all articles
Browse latest Browse all 8500

DB2 :: RE: SQL Query optimization.

$
0
0
Author: Akatsukami
Posted: Mon Sep 05, 2016 12:13 am (GMT 5.5)

arunsoods wrote:
Nic - If i create INDEX as below on the table

CREATE INDEX INX_SEQ_ID
ON test_table (SEQ_ID)

and then run this query

EXEC SQL
SELECT MAX(SEQ_ID)
INTO :DCLTB99-TRANS.SEQ-ID
:SOF-TRANS-SEQ-ID
FROM TEST_TABLE
END-EXEC

Will this reduce the cost...??

Almost certainly.
Quote:
Bill - "Can't you store the value somewhere when you know it, rather than lazily rummaging about for the highest one?."

By the above do you mean that if I select all SEQ_ID using below query.

SELECT SEQ_ID FROM TEST_TABLE

and store the values in a PS file and then applying SORT to find the highest...

Will this work...???

I believe that what Mr. Woodger meant was to run the query once, and then to reuse either DCLTB99-TRANS.SEQ-ID OR SOF-TRANS-SEQ-ID , whichever you decide to derive directly from the DB2 table.
_________________
Data is not information.
Information is not knowledge.
Knowledge is not wisdom.


Viewing all articles
Browse latest Browse all 8500

Trending Articles