I recently found that gh-ost occasionally executes slowly in MySQL 8.0.
When copying data to the _gho table, querys for Iteration Range End Values occationally use the wrong index due to inappropriate optimizer selection.
I think we can force the unique-key index to avoid inappropriate optimizer selection, in BuildUniqueKeyRangeEndPreparedQueryViaOffset and BuildUniqueKeyRangeEndPreparedQueryViaTemptable. Just like unique key range queries do in #1237 .
I'd like to contribute the patch, if you agree.