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

DB2 :: RE: SQL Query optimization.

$
0
0
Author: arunsoods
Posted: Sun Sep 04, 2016 11:35 pm (GMT 5.5)

Thanks Bill and Nic for replying...

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...??

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...???
Please suggest icon_idea.gif
_________________
Arun Sood


Viewing all articles
Browse latest Browse all 8500

Trending Articles