MDL-31495 Performance improvement in question engine upgrade SQL