CREATETABLEIFNOTEXISTStable_stats(db_namevarchar(64)NOTNULL,table_namevarchar(64)NOTNULL,cardinalitybigint(21)unsignedDEFAULTNULL,PRIMARYKEY(db_name,table_name))engine=Ariatransactional=0CHARACTERSETutf8COLLATEutf8_bincomment='Statistics on Tables';
CREATETABLEIFNOTEXISTScolumn_stats(db_namevarchar(64)NOTNULL,table_namevarchar(64)NOTNULL,column_namevarchar(64)NOTNULL,min_valuevarbinary(255)DEFAULTNULL,max_valuevarbinary(255)DEFAULTNULL,nulls_ratiodecimal(12,4)DEFAULTNULL,avg_lengthdecimal(12,4)DEFAULTNULL,avg_frequencydecimal(12,4)DEFAULTNULL,hist_sizetinyintunsigned,hist_typeenum('SINGLE_PREC_HB','DOUBLE_PREC_HB'),histogramvarbinary(255),PRIMARYKEY(db_name,table_name,column_name))engine=Ariatransactional=0CHARACTERSETutf8COLLATEutf8_bincomment='Statistics on Columns';
CREATETABLEIFNOTEXISTScolumn_stats(db_namevarchar(64)NOTNULL,table_namevarchar(64)NOTNULL,column_namevarchar(64)NOTNULL,min_valuevarbinary(255)DEFAULTNULL,max_valuevarbinary(255)DEFAULTNULL,nulls_ratiodecimal(12,4)DEFAULTNULL,avg_lengthdecimal(12,4)DEFAULTNULL,avg_frequencydecimal(12,4)DEFAULTNULL,hist_sizetinyintunsigned,hist_typeenum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON'),histogramvarbinary(255),PRIMARYKEY(db_name,table_name,column_name))engine=Ariatransactional=0CHARACTERSETutf8COLLATEutf8_bincomment='Statistics on Columns';
CREATETABLEIFNOTEXISTSindex_stats(db_namevarchar(64)NOTNULL,table_namevarchar(64)NOTNULL,index_namevarchar(64)NOTNULL,prefix_arityint(11)unsignedNOTNULL,avg_frequencydecimal(12,4)DEFAULTNULL,PRIMARYKEY(db_name,table_name,index_name,prefix_arity))engine=Ariatransactional=0CHARACTERSETutf8COLLATEutf8_bincomment='Statistics on Indexes';