New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sql: add support for ANALYZE <tablename> #49816
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @otan, @RaduBerinde, and @rytaft)
pkg/sql/sem/tree/analyze.go, line 20 at r1 (raw file):
// Format implements the NodeFormatter interface. func (node *Analyze) Format(ctx *FmtCtx) { ctx.WriteString("ANALYZE ")
I think we're missing the corresponding code in pretty.go
. We should add some parsing tests with the new statement to parse_test.go, I think that would have exposed this.
This commit adds support for `ANALYZE <tablename>` by adding the statement as syntactic sugar for the equivalent command `CREATE STATISTICS "" FROM <tablename>`. This improves compatibility with Postgres, and is needed to run the PostGIS tutorial as written. Note that this commit does not add support for `ANALYZE` without a table name. We can add support for that and other variants later if needed, but it is not necessary for the PostGIS tutorial. Fixes cockroachdb#49214 Release note (sql change): Added support for `ANALYZE <tablename>`, which causes the database to collect statistics on the given table for use by the optimizer. The functionality of this command is equivalent to the existing command `CREATE STATISTICS "" FROM <tablename>`, but it increases compatibility with Postgres by using the same syntax that Postgres uses.
pkg/sql/sem/tree/analyze.go, line 20 at r1 (raw file): Previously, RaduBerinde wrote…
Doesn't seem like I need to add anything to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @otan and @rytaft)
pkg/sql/sem/tree/analyze.go, line 20 at r1 (raw file):
Previously, rytaft (Rebecca Taft) wrote…
Doesn't seem like I need to add anything to
pretty.go
(CREATE STATISTICS
doesn't have anything there either...) but good call about adding toparse_test.go
. Added tests there andhelp_test.go
Ah, I guess there is a "default" that works for simple statements, good to know!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build succeeded |
This commit adds support for
ANALYZE <tablename>
by adding thestatement as syntactic sugar for the equivalent command
CREATE STATISTICS "" FROM <tablename>
. This improves compatibilitywith Postgres, and is needed to run the PostGIS tutorial as written.
Note that this commit does not add support for
ANALYZE
without atable name. We can add support for that and other variants later if
needed, but it is not necessary for the PostGIS tutorial.
Fixes #49214
Release note (sql change): Added support for
ANALYZE <tablename>
,which causes the database to collect statistics on the given table for
use by the optimizer. The functionality of this command is equivalent
to the existing command
CREATE STATISTICS "" FROM <tablename>
, butit increases compatibility with Postgres by using the same syntax that
Postgres uses.