Skip to content

sql: generate statistics for materialized views #78181

@whatdoidoherereally

Description

@whatdoidoherereally

Describe the problem

I joined three tables into a materialized view in my database, but I am not observing any auto-statistic creation jobs running on the view, nor am I able to manual create the statistics, instead receiving the following error:

root@test-db:26257/test> analyze test_view_v0_0;
ERROR: "test_view_v0_0" is not a table
SQLSTATE: 42809

To Reproduce

  1. Create two tables
  2. Create view from both tables, no functions used, just denormalizing the data
  3. Create a few non-covering indexes on the view also.
  4. Observe that stats are not created, nor can you manually run Analyze or CREATE STATISTICS

Expected behavior
I would expect to be able to generate statistics on a materialized view and it's indices.

Environment:

  • CockroachDB version 21.2.5

Additional context
Attempting to optimize queries on an extremely large dataset are not using the intended indexes due to lack of statistics

Jira issue: CRDB-14007
Epic: CRDB-13625

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-sql-table-statsTable statistics (and their automatic refresh).C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.E-quick-winLikely to be a quick win for someone experienced.O-communityOriginated from the communityT-sql-queriesSQL Queries Team

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions