Skip to content
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

table stats: automatic statistics on empty tables in some cases but not others #37362

Closed
RaduBerinde opened this issue May 7, 2019 · 0 comments · Fixed by #37611
Closed

table stats: automatic statistics on empty tables in some cases but not others #37362

RaduBerinde opened this issue May 7, 2019 · 0 comments · Fixed by #37611
Assignees

Comments

@RaduBerinde
Copy link
Member

I noticed the following behavior: if I create two empty tables, I don't get any statistics for them. But then if I create an index for one of them, that table does get statistics. At this point we have one table with statistics (which show 0 rows) and one without statistics (for which we assume 1000 rows). This leads to unexpected plans (e.g. lookup joins).

I am not sure if this is only a problem with empty tables, or also with tables that are small enough to not trigger the collection.

CC @awoods187

rytaft added a commit to rytaft/cockroach that referenced this issue May 21, 2019
Prior to this commit, we only collected automatic statistics on a
CREATE TABLE statement if it was of the form CREATE TABLE AS <query>.
To avoid inconsistencies, this commit changes the logic so we always
create statistics on every successful CREATE TABLE statement.

Fixes cockroachdb#37362

Release note (sql change): CREATE TABLE statements now always trigger automatic
statistics collection on the newly created table.
craig bot pushed a commit that referenced this issue May 21, 2019
37611: sql: always collect stats after a table is created r=rytaft a=rytaft

Prior to this commit, we only collected automatic statistics on a
`CREATE TABLE` statement if it was of the form `CREATE TABLE AS <query>`.
To avoid inconsistencies, this commit changes the logic so we always
create statistics on every successful `CREATE TABLE` statement.

Fixes #37362

Release note (sql change): CREATE TABLE statements now always trigger automatic
statistics collection on the newly created table.

Co-authored-by: Rebecca Taft <[email protected]>
@craig craig bot closed this as completed in #37611 May 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants