ALM-167 small SQL optimization