Cockroach: ui: add query plan inspector

Created on 3 Jan 2017  Â·  15Comments  Â·  Source: cockroachdb/cockroach

So @RaduBerinde, @andreimatei and myself have recently found ourselves in want of this feature, so much that we have started to implement part of it (see below), but this was done outside of our product because we don't know to extend the UI code ourselves.

The desired feature is a new page in the UI application called "Query Inspector" which should more or less look like this:

  • in the admin RPC code, a new endpoint "AnalyzeQuery" which:

    • takes as input a single string with SQL code, and

    • returns two JSON objects,

    • one for the logical plan (code remaining to write)

    • and one for the physical plan (code partially written already; distSQL part already implemented)

  • in the UI 3 sections organized vertically:

    1. a text input widget where the user can enter SQL code, titled "Query"
    2. an initially empty canvas titled "Logical plan", updated using the RPC results when the user updates the text widget.
    3. an initially empty canvas titled "Physical plan", updated using the RPC results when the user updates the text widget.

    Both canvases would run the graph visualisation interface already prototyped by Radu on https://raduberinde.github.io/

Note: this feature is not about running the query and inspecting its results. This would be quite more complicated to achieve! and not as useful I think, because we already have plenty of tools / apps to run queries.

To give you an idea of how much we're suffering, consider that we currently achieve this by the following steps across at least 3 screens:

  1. start the server with some environment variables set (COCKROACH_DISTSQL_LOG_PLAN=1) and verbose logging enabled
  2. run some query using the CLI shell
  3. select the JSON code produced by the server in its log messages to the clipboard
  4. open a browser to Radu's viz on https://raduberinde.github.io/
  5. click "start again"
  6. paste the clipboard contents
  7. click "generate graph"
  8. start at step 2 for every other query we want to inspect.
A-webui-queryperf C-enhancement help wanted

Most helpful comment

@RaduBerinde @andreimatei @knz I was thinking about picking this up—at least a draft implementation that tackles most of the UI work—in the next week or so, in between work on my starter project. Is this still needed/is that timeline okay?

All 15 comments

Remark by @petermattis: this could be a "hidden" page like we already hide "raft" and "ranges".

/debug pages are meant for quickly adding developer targeted debugging aids, which is exactly what you're after here.

Happy to contribute to the design of this project, @knz, @RaduBerinde, @andreimatei! Let me know if you guys want to set up a time to quickly chat about this, and see what we can do to make this less painful.

@RaduBerinde @andreimatei @knz I was thinking about picking this up—at least a draft implementation that tackles most of the UI work—in the next week or so, in between work on my starter project. Is this still needed/is that timeline okay?

Y E S — Ⓨ Ⓔ Ⓢ — Ꙅ Ǝ Y — ⒴ ⒠ ⒮

BTW I was thinking of adding an EXPLAIN (DISTSQL) that prints out the plan JSON and this link.

It's neat but 1) I don't want to rely on a separate public web site for this (what about privacy / confidentiality) 2) it's a single point of failure 3) it doesn't work if you're not connected to the internet.

Ideally we'd use your html/json and bake it in our UI generator.

Sure, I was just mentioning it because it's easier in the interim.

If this Query Inspector screen would also display tracing information, I could die a happy man :)
For context, @benesch, we have some work in progress tracing work that makes it pretty easy to get (distributed) tracing information for a query. We can talk about it if you're interested.

@knz, are you still planning on/hoping for a logical query plan? The physical half of this is done!

Yes working on it now :-)

Sent from my Android device with K-9 Mail. Please excuse my brevity.

Sadly @jrbotros's work rotted a bit (it had stopped working, and wasn't linked to from anywhere) and was deleted. It'd be nice to have it back, but It seems EXPLAIN (DISTSQL) has somewhat relieved the pain for internal devs which motivated this.

Also, @dianasaur323, myself and others have started talking about it again as a user-facing feature (probably 2.2 timeframe), that you get to from a new "workload" screen which has a table of query fingerprints. Click a fingerprint, get a representative plan. (The notion of "representative plan" needs some refinement).

looking forward to this being implemented in the DistSQL or something else

This is done now, in the statements page.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

couchand picture couchand  Â·  3Comments

melskyzy picture melskyzy  Â·  3Comments

jordanlewis picture jordanlewis  Â·  4Comments

petermattis picture petermattis  Â·  4Comments

lwsanty picture lwsanty  Â·  4Comments