stats: add explicit AOST syntax to ANALYZE #96430
Labels
C-enhancement
Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
docs-done
docs-known-limitation
T-sql-queries
SQL Queries Team
Projects
Is your feature request related to a problem? Please describe.
When you run an explain command, the engine may report back saying to run ANALYZE and not CREATE STATS. If you run ANALYZE and look at the schema jobs, you'll see CREATE STATS WITH OPTIONS AS OF SYSTEM TIME. Running ANALYZE with AOST explicitly will break however, even though they are analogous.
Describe the solution you'd like
I understand that ANALYZE runs with AOST in the background and adding syntactic sugar is redundant but perhaps a bit confusing to the end user as executing CREATE STATS WITH AOST explicitly works. There's also an opportunity to run ANALYZE with a different AOST interval than default. Yes, then you can just run CREATE STATS with that interval but we also should strive for being consistent.
From Yahor:
The syntax I imagine should be
ANALYZE t1 AS OF SYSTEM TIME
. I'm surprised CREATE STATS syntax isCREATE STATISTICS "" FROM t1 WITH OPTIONS AS OF SYSTEM TIME
but there must be a good reason to useWITH OPTIONS
, which is not common to the other uses of AOST for backups, SELECT, etc.Describe alternatives you've considered
Run CREATE STATS WITH AOST instead.
Additional context
CREATE STATISTICS "" FROM t1 WITH OPTIONS AS OF SYSTEM TIME '-0.001ms';
and
ANALYZE t1 WITH OPTIONS AS OF SYSTEM TIME '-0.001ms';
is not possible? I did tryANALYZE t1 AS OF SYSTEM TIME '-0.001ms';
and it doesn’t work either.The following however works
Jira issue: CRDB-24121
The text was updated successfully, but these errors were encountered: