Skip to content

Reimplement: Printer for the plan, ie: EXPLAIN #4793

@clockwork-labs-bot

Description

@clockwork-labs-bot

This issue tracks reimplementation of the work from stale PR #2075, which is being closed because it is too out of date to merge directly.

    Original PR: https://github.com/clockworklabs/SpacetimeDB/pull/2075
    Original author: @mamcx
    Original branch: `mamcx/planner-printer`
    Base branch: `master`

    ## Original PR summary

    # Description of Changes

Incipient support for EXPLAIN with close plan output as in Postgres (but not yet conformant).

It has the extra capability of showing extra metadata about the schema & indexes, useful for testing & debugging.

Example:

-- Without metadata
Nested Loop
  -> Index Scan using Index id 0 Unique(m.employee) on m
     Index Cond: (m.employee = U64(1))
     Output: m.employee, m.manager
  -> Seq Scan on p
     Output: p.id, p.name
  Output: m.employee, m.manager, p.id, p.name
Planning Time: 541.5µs

-- With metadata
Query: SELECT m.* FROM m CROSS JOIN p WHERE m.employee = 1
Nested Loop
  -> Index Scan using Index id 0 Unique(m.employee) on m
     Index Cond: (m.employee = U64(1))
     Output: m.employee, m.manager
  -> Seq Scan on p:2
     Output: p.id, p.name
  Output: m.employee, m.manager, p.id, p.name
-------
Schema:

Label: m, TableId:1
  Columns: employee, manager
  Indexes: Index id 0 Unique(m.employee) on m, Index id 1 (m.manager) on m
  Constraints: Constraint id 0: Unique(m.employee)
Label: p, TableId:3
  Columns: id, name
  Indexes: Index id 0 Unique(p.id) on p
  Constraints: Constraint id 0: Unique(p.id)

Closes #2058.

API and ABI breaking changes

None

Expected complexity level and risk

1

Testing

  • Adding testing for both optimized or not variations of the plan

  • WILL NEED more test but is likely that we need to do another pr

      ## Follow-up
    
      - Reimplement this change in a fresh PR against current `master`.
      - Carry forward any still-relevant context from the original PR discussion and review.
      - Link the new implementation PR back to the original stale PR for historical context.
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    release-anyTo be landed in any release window

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions