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

opt: add node and region information to explain #59860

Closed
awoods187 opened this issue Feb 5, 2021 · 4 comments
Closed

opt: add node and region information to explain #59860

awoods187 opened this issue Feb 5, 2021 · 4 comments
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) no-issue-activity X-stale

Comments

@awoods187
Copy link
Contributor

awoods187 commented Feb 5, 2021

Distributed SQL allows for queries to be distributed across multiple nodes, and, potentially multiple regions. Furthermore, as we enhance our support for multi-region, some data may not be located in every region. Developers will need to be able to write queries that go cross-node and even cross-region. We want to minimize cross-region queries wherever possible because of the expensive cross-region network hop that can dramatically increase latency. By adding regions involved in the query to EXPLAIN, developers can identify costly cross-region queries and take corrective action.

Cross-node queries are somewhat more complex as it is not always advantageous for a query to use multiple nodes. Sometimes using multiple nodes enhances query performance by sharing resources, and sometimes it increases latency due to the distance between nodes.

We need to include this information on a per-operator basis because otherwise developers would not be able to identify the problematic part of the query that travels cross-node or cross-region usage.

New Field Information Details Example
Regions involved in query List of all regions us-east, us-west
Regions involved per operator List of all regions us-east, us-west
Nodes involved in query List of all nodes n1, n2, n3
Nodes involved per operator List of all nodes n1, n2, n3

Epic: CRDB-9025

Jira issue: CRDB-3220

@awoods187 awoods187 added the C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) label Feb 5, 2021
craig bot pushed a commit that referenced this issue Feb 19, 2021
60550: sql: add nodes for each EXPLAIN ANALYZE operator r=RaduBerinde a=RaduBerinde

Show the cluster nodes involved in the execution of each operator.

Note that this info does not show up in the non-analyze EXPLAIN. It is
technically much more challenging to do that because of the indirect
way we do distsql planning. Once we have the new DistSQL exec factory,
we will be able to add it.

Note on the implementation: I started by trying to make execution set
`ComponentID.NodeID` in all cases, but I got stuck in `ProcessorBase`
where we only have a `SQLIDContainer` available. I don't fully
understand the new abstraction and whether the distsql components and
flows should really use SQLIDs instead of NodeIDs.

Unfortunately, there is not much we can do to test this currently
(other than manual testing). I will investigate making the
"deterministic" flag more fine-grained, so that we can hide truly
non-deterministic values (like timings) separately from those that
just vary with the configuration (query distribution).

Example:
```
movr> EXPLAIN ANALYZE SELECT * FROM rides JOIN vehicles ON rides.vehicle_id = vehicles.id;
                    info
--------------------------------------------
  planning time: 158µs
  execution time: 7ms
  distribution: full
  vectorized: true

   hash join
  │ cluster nodes: n1, n2, n3
  │ actual row count: 500
  │ equality: (vehicle_id) = (id)
  │
  ├──  scan
  │     cluster nodes: n1, n2, n3
  │     actual row count: 500
  │     KV rows read: 500
  │     KV bytes read: 86 KiB
  │     missing stats
  │     table: rides@primary
  │     spans: FULL SCAN
  │
  └──  scan
        cluster nodes: n1, n2, n3
        actual row count: 15
        KV rows read: 15
        KV bytes read: 2.3 KiB
        missing stats
        table: vehicles@primary
        spans: FULL SCAN
```

Release note (sql change): EXPLAIN ANALYZE now includes the nodes
which were involved in the execution of each operator in the tree.

Informs #59860.

60748: sql: remove experimental setting for virtual columns r=RaduBerinde a=RaduBerinde

Informs #57608.

Release note (sql change): CockroachDB now supports VIRTUAL computed
columns (as opposed to STORED). These are computed columns that are
not stored in the primary index and are recomputed as necessary.

Co-authored-by: Radu Berinde <radu@cockroachlabs.com>
@awoods187
Copy link
Contributor Author

@RaduBerinde could you update here why we only added this to explain analyze?

@RaduBerinde
Copy link
Member

#60550 added per-operator node information for EXPLAIN ANALYZE. Adding this info to the regular EXPLAIN is currently difficult, because we don't generate the distsql plan directly. This will be easier once we do (with the distsql factory).

@jlinder jlinder added the T-sql-queries SQL Queries Team label Jun 16, 2021
@jordanlewis
Copy link
Member

The work that @RaduBerinde is mentioning is tracked here: #47473

@exalate-issue-sync exalate-issue-sync bot removed the T-sql-queries SQL Queries Team label Feb 1, 2022
@github-actions
Copy link

github-actions bot commented Sep 5, 2023

We have marked this issue as stale because it has been inactive for
18 months. If this issue is still relevant, removing the stale label
or adding a comment will keep it active. Otherwise, we'll close it in
10 days to keep the issue queue tidy. Thank you for your contribution
to CockroachDB!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) no-issue-activity X-stale
Projects
No open projects
Development

No branches or pull requests

4 participants