From 3632c0500d783027dc254fcbab0a3d7778e4af1b Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Fri, 31 Jan 2025 14:47:19 -0500 Subject: [PATCH] Don't use index hint if there are pushdown expressions Signed-off-by: Matt Lord --- go/vt/vttablet/tabletserver/vstreamer/rowstreamer.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/go/vt/vttablet/tabletserver/vstreamer/rowstreamer.go b/go/vt/vttablet/tabletserver/vstreamer/rowstreamer.go index 21592151d03..f46dcf61387 100644 --- a/go/vt/vttablet/tabletserver/vstreamer/rowstreamer.go +++ b/go/vt/vttablet/tabletserver/vstreamer/rowstreamer.go @@ -280,7 +280,9 @@ func (rs *rowStreamer) buildSelect(st *binlogdatapb.MinimalTable) (string, error // do a FILESORT of all the results. This index should contain all // of the PK columns which are used in the ORDER BY clause below. var indexHint string - if st.PKIndexName != "" { + // If we're pushing down any expressions, we need to let the optimizer + // choose the best index to use. + if st.PKIndexName != "" && len(rs.plan.whereExprsToPushDown) == 0 { escapedPKIndexName, err := sqlescape.EnsureEscaped(st.PKIndexName) if err != nil { return "", err