We have a slow SQL in DB2 running over 10 seconds. One of index clustering ratio is too low and can’t be easily improved without affecting other indexes. One workaround we found is to increase DB2 ‘s query optimazation level from 2 to 3 for this SQL only.
I used Jython for a quick proof of concept. It only takes like 5 minutes of my time.
stmt.execute("set current query optimization 2")
rs = stmt.executeQuery(slowSQL)
stmt.execute("set current query optimization 3")
This slowSQL now run under subseconds now. amazing.