github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/opt/optbuilder/testdata/explain (about)

     1  exec-ddl
     2  CREATE TABLE xy (x INT PRIMARY KEY, y INT)
     3  ----
     4  
     5  build
     6  EXPLAIN SELECT * FROM xy
     7  ----
     8  explain
     9   ├── columns: tree:3 field:4 description:5
    10   └── scan xy
    11        └── columns: x:1!null y:2
    12  
    13  build
    14  EXPLAIN (PLAN,SYMVARS) SELECT * FROM xy
    15  ----
    16  explain
    17   ├── columns: tree:3 field:4 description:5
    18   └── scan xy
    19        └── columns: x:1!null y:2
    20  
    21  build
    22  EXPLAIN (TYPES) SELECT * FROM xy
    23  ----
    24  explain
    25   ├── columns: tree:3 field:6 description:7 columns:8 ordering:9  [hidden: level:4 node_type:5]
    26   └── scan xy
    27        └── columns: x:1!null y:2
    28  
    29  build
    30  EXPLAIN (VERBOSE) SELECT * FROM xy
    31  ----
    32  explain
    33   ├── columns: tree:3 field:6 description:7 columns:8 ordering:9  [hidden: level:4 node_type:5]
    34   ├── mode: verbose
    35   └── scan xy
    36        └── columns: x:1!null y:2
    37  
    38  # Verify we preserve the ordering requirement of the explained query.
    39  build
    40  EXPLAIN (VERBOSE) SELECT * FROM xy ORDER BY y
    41  ----
    42  explain
    43   ├── columns: tree:3 field:6 description:7 columns:8 ordering:9  [hidden: level:4 node_type:5]
    44   ├── mode: verbose
    45   └── sort
    46        ├── columns: x:1!null y:2
    47        ├── ordering: +2
    48        └── scan xy
    49             └── columns: x:1!null y:2
    50  
    51  build
    52  EXPLAIN (VERBOSE) SELECT * FROM xy INNER JOIN (VALUES (1, 2), (3, 4)) AS t(u,v) ON x=u
    53  ----
    54  explain
    55   ├── columns: tree:5 field:8 description:9 columns:10 ordering:11  [hidden: level:6 node_type:7]
    56   ├── mode: verbose
    57   └── inner-join (hash)
    58        ├── columns: x:1!null y:2 u:3!null v:4!null
    59        ├── scan xy
    60        │    └── columns: x:1!null y:2
    61        ├── values
    62        │    ├── columns: column1:3!null column2:4!null
    63        │    ├── (1, 2)
    64        │    └── (3, 4)
    65        └── filters
    66             └── x:1 = column1:3
    67  
    68  build
    69  SELECT tree FROM [ EXPLAIN (VERBOSE) SELECT * FROM xy ]
    70  ----
    71  with &1
    72   ├── columns: tree:10
    73   ├── explain
    74   │    ├── columns: tree:3 level:4 node_type:5 field:6 description:7 columns:8 ordering:9
    75   │    ├── mode: verbose
    76   │    └── scan xy
    77   │         └── columns: x:1!null y:2
    78   └── project
    79        ├── columns: tree:10
    80        └── with-scan &1
    81             ├── columns: tree:10 level:11 node_type:12 field:13 description:14 columns:15 ordering:16
    82             └── mapping:
    83                  ├──  tree:3 => tree:10
    84                  ├──  level:4 => level:11
    85                  ├──  node_type:5 => node_type:12
    86                  ├──  field:6 => field:13
    87                  ├──  description:7 => description:14
    88                  ├──  columns:8 => columns:15
    89                  └──  ordering:9 => ordering:16
    90  
    91  build
    92  SELECT tree FROM [ EXPLAIN (VERBOSE) SELECT x, x, y FROM xy ORDER BY y ]
    93  ----
    94  with &1
    95   ├── columns: tree:10
    96   ├── explain
    97   │    ├── columns: tree:3 level:4 node_type:5 field:6 description:7 columns:8 ordering:9
    98   │    ├── mode: verbose
    99   │    └── sort
   100   │         ├── columns: x:1!null x:1!null y:2
   101   │         ├── ordering: +2
   102   │         └── scan xy
   103   │              └── columns: x:1!null y:2
   104   └── project
   105        ├── columns: tree:10
   106        └── with-scan &1
   107             ├── columns: tree:10 level:11 node_type:12 field:13 description:14 columns:15 ordering:16
   108             └── mapping:
   109                  ├──  tree:3 => tree:10
   110                  ├──  level:4 => level:11
   111                  ├──  node_type:5 => node_type:12
   112                  ├──  field:6 => field:13
   113                  ├──  description:7 => description:14
   114                  ├──  columns:8 => columns:15
   115                  └──  ordering:9 => ordering:16
   116  
   117  build
   118  SELECT json FROM [EXPLAIN (DISTSQL) SELECT * FROM xy] WHERE false
   119  ----
   120  with &1
   121   ├── columns: json:8
   122   ├── explain
   123   │    ├── columns: automatic:3 url:4 json:5
   124   │    ├── mode: distsql
   125   │    └── scan xy
   126   │         └── columns: x:1!null y:2
   127   └── project
   128        ├── columns: json:8
   129        └── select
   130             ├── columns: automatic:6 url:7 json:8
   131             ├── with-scan &1
   132             │    ├── columns: automatic:6 url:7 json:8
   133             │    └── mapping:
   134             │         ├──  automatic:3 => automatic:6
   135             │         ├──  url:4 => url:7
   136             │         └──  json:5 => json:8
   137             └── filters
   138                  └── false
   139  
   140  # Don't include hidden columns on a SELECT *.
   141  build
   142  SELECT * FROM [EXPLAIN (DISTSQL) SELECT * FROM xy] WHERE false
   143  ----
   144  with &1
   145   ├── columns: automatic:6 url:7
   146   ├── explain
   147   │    ├── columns: automatic:3 url:4 json:5
   148   │    ├── mode: distsql
   149   │    └── scan xy
   150   │         └── columns: x:1!null y:2
   151   └── project
   152        ├── columns: automatic:6 url:7
   153        └── select
   154             ├── columns: automatic:6 url:7 json:8
   155             ├── with-scan &1
   156             │    ├── columns: automatic:6 url:7 json:8
   157             │    └── mapping:
   158             │         ├──  automatic:3 => automatic:6
   159             │         ├──  url:4 => url:7
   160             │         └──  json:5 => json:8
   161             └── filters
   162                  └── false