pingcap / tidb

TiDB - the open-source, cloud-native, distributed SQL database designed for modern applications.
https://pingcap.com
Apache License 2.0
37.14k stars 5.83k forks source link

[RFC] Query Plan Graph #4049

Open unship opened 7 years ago

unship commented 7 years ago

Summary

Add query plan graph to tidb's Web UI

Motivation

A sql query plan can be abstracted as a DAG which can be interactively visualized in browser as cockroach's init implementation of query plan graph @ QueryPlanGraph , and neo4j's implementation @ PlanView

Query Plan Graph can let user intuitively reasoning about how DB process sql to get data, and may help optimize their sql

Detailed design

Tensorflow is designed to be a computation engine which have some similarity with tidb stack, its monitor tool TensorBoard have DAG visualisation modul

Nodes and Edges can Represent operator and data flow

Symbol Meaning
Name scope High-level node representing a name scope. It can be a Raft group or tikv node, Double-click to expand to a set of operator running in this node
Sequence of unconnected nodes Sequence of numbered nodes that are not connected to each other. It's a bunch of parallel operator
Sequence of connected nodes Sequence of numbered nodes that are connected to each other. It's a bunch of sequential operator
Operation node An individual operation node. It's a operator which have "next" method
Constant node A constant. It's parameter of the tidb stack cluster
Summary node A summary node. It's prometheus monitor value
Data flow edge Edge showing the data flow between operations. It's grpc between nodes, it's width is throughput between nodes

Outcome is Visualization of a TensorFlow graph

port from Tensorflow Doc

shenli commented 7 years ago

@biolee Thanks for your advice! @iamxy PTAL

shenli commented 7 years ago

This PR is related with query graph: https://github.com/pingcap/tidb/pull/3933/files

zz-jason commented 7 years ago

nice, LGTM !

morgo commented 5 years ago

It would be nice to see this + also an execution view (explain analyze) as a flame graph, directly through the status port :-)