From 208651922a820e30130bc5bc12916e056eba9713 Mon Sep 17 00:00:00 2001 From: Lonng Date: Wed, 29 May 2019 11:49:01 +0800 Subject: [PATCH] planner: ignore the virtual column when collect statistics (#10623) (#10628) --- planner/core/planbuilder.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/planner/core/planbuilder.go b/planner/core/planbuilder.go index 21de7c0e2bef9..b6bab0f1d8e6f 100644 --- a/planner/core/planbuilder.go +++ b/planner/core/planbuilder.go @@ -665,6 +665,10 @@ func (b *planBuilder) buildCheckIndexSchema(tn *ast.TableName, indexName string) func getColsInfo(tn *ast.TableName) (indicesInfo []*model.IndexInfo, colsInfo []*model.ColumnInfo, pkCol *model.ColumnInfo) { tbl := tn.TableInfo for _, col := range tbl.Columns { + // The virtual column will not store any data in TiKV, so it should be ignored when collect statistics + if col.IsGenerated() && !col.GeneratedStored { + continue + } if tbl.PKIsHandle && mysql.HasPriKeyFlag(col.Flag) { pkCol = col } else {