Repository navigation
*: create / drop extended stats by ALTER TABLE - #1138
Conversation
| sqlSmallResult "SQL_SMALL_RESULT" | ||
| ssl "SSL" | ||
| starting "STARTING" | ||
| statistics "STATISTICS" |
There was a problem hiding this comment.
This would make statistics a reserved keyword, while in previous syntax implementation, it is just a TiDB keyword. If we don't do this, the newly added rule would have shift/reduce conflict with ColumnKeywordOpt, because statistics can be treated as a column name for ADD [COLUMN] statistics.
There was a problem hiding this comment.
Making statistics or stats a reserved keyword just to avoid having the "frankenstein" CREATE STATISTICS syntax (already used by T-SQL and PostgreSQL) is not a good trade-off imo.
There was a problem hiding this comment.
For better syntax compatibility with MySQL, I think it's worthy.
There was a problem hiding this comment.
and what about TIDB_STATS / TIDB_STATISTICS 🤔
There was a problem hiding this comment.
I agree with kennytm. stats / statistics is not a reserved word in the SQL standard, or in MySQL. It doesn't hurt usability too much to use TIDB_STATISTICS or OPTIMIZER_STATISTICS instead.
There was a problem hiding this comment.
Alright, I replaced statistics with tidb_stats, shall we use admin reload statistics or admin reload tidb_stats then?
There was a problem hiding this comment.
I like the consistency of admin reload tidb_stats, but not a strong opinion.
There was a problem hiding this comment.
If we choose tidb_stats, lots of SQL grammar might need to be modified to keep consistency.
For example, some SQL syntaxes:
show stats_meta;
load stats;Config:
stats-lease = "3s"
HTTP API:
http://$host:$port/stats/dump/$db/$table
And some tables:
stats_buckets
stats_feedback
stats_histograms
stats_meta
stats_top_n
keeping the name to be consistent helps users to easily remember these concepts. I prefer to use stats for drop and alter table statements.
There was a problem hiding this comment.
What about replacing TIDB_STATS with STATS_EXTENDED to keep consistency? @zz-jason
ALTER TABLE t ADD stats_extended s1 dependency(a,b);
ALTER TABLE t DROP stats_extended s1;
ADMIN RELOAD stats_extended;
or maybe a shorter STATS_EXT?
7032e32 to
82aeaaa
Compare
What problem does this PR solve?
Change the extended statistics SQL interfaces according to https://docs.google.com/document/d/1rRIQ8ekoKJH8qeB-J15QRaycLys8_19GBnij7q_O7Vg/edit.
What is changed and how it works?
Use
ALTER TABLE ... ADD / DROP STATISTICSsyntax for create / drop extended statistics. Old syntax in #913 would be removed later once the new syntax support is finished.Check List
Tests
Code changes
Side effects
Related changes
N/A