Backport DB2 query improvement from 5.4 to 5.2.3