From 2c03f51cbe21e13ffb95dfb93d09c8708b2a9dea Mon Sep 17 00:00:00 2001 From: Lonng Date: Wed, 29 May 2019 11:04:36 +0800 Subject: [PATCH] planner: ignore the virtual column when collect statistics (#10623) Signed-off-by: Lonng --- planner/core/planbuilder.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/planner/core/planbuilder.go b/planner/core/planbuilder.go index be8b3843f59ba..d0e8d36bdc6eb 100644 --- a/planner/core/planbuilder.go +++ b/planner/core/planbuilder.go @@ -754,6 +754,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 {