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

     1  exec-ddl
     2  CREATE TABLE xyzs (x INT PRIMARY KEY, y INT, z FLOAT NOT NULL, s STRING, UNIQUE (s DESC, z))
     3  ----
     4  
     5  exec-ddl
     6  CREATE TABLE kuv (k INT PRIMARY KEY, u FLOAT, v STRING)
     7  ----
     8  
     9  build
    10  SELECT * FROM xyzs LIMIT 1
    11  ----
    12  limit
    13   ├── columns: x:1(int!null) y:2(int) z:3(float!null) s:4(string)
    14   ├── cardinality: [0 - 1]
    15   ├── key: ()
    16   ├── fd: ()-->(1-4)
    17   ├── prune: (1-4)
    18   ├── interesting orderings: (+1) (-4,+3,+1)
    19   ├── scan xyzs
    20   │    ├── columns: x:1(int!null) y:2(int) z:3(float!null) s:4(string)
    21   │    ├── key: (1)
    22   │    ├── fd: (1)-->(2-4), (3,4)~~>(1,2)
    23   │    ├── limit hint: 1.00
    24   │    ├── prune: (1-4)
    25   │    └── interesting orderings: (+1) (-4,+3,+1)
    26   └── const: 1 [type=int]
    27  
    28  build
    29  SELECT count(*) FROM xyzs LIMIT 10
    30  ----
    31  limit
    32   ├── columns: count:5(int!null)
    33   ├── cardinality: [1 - 1]
    34   ├── key: ()
    35   ├── fd: ()-->(5)
    36   ├── prune: (5)
    37   ├── scalar-group-by
    38   │    ├── columns: count_rows:5(int!null)
    39   │    ├── cardinality: [1 - 1]
    40   │    ├── key: ()
    41   │    ├── fd: ()-->(5)
    42   │    ├── limit hint: 10.00
    43   │    ├── prune: (5)
    44   │    ├── project
    45   │    │    └── scan xyzs
    46   │    │         ├── columns: x:1(int!null) y:2(int) z:3(float!null) s:4(string)
    47   │    │         ├── key: (1)
    48   │    │         ├── fd: (1)-->(2-4), (3,4)~~>(1,2)
    49   │    │         ├── prune: (1-4)
    50   │    │         └── interesting orderings: (+1) (-4,+3,+1)
    51   │    └── aggregations
    52   │         └── count-rows [as=count_rows:5, type=int]
    53   └── const: 10 [type=int]
    54  
    55  build
    56  SELECT * FROM xyzs LIMIT (SELECT 1)
    57  ----
    58  limit
    59   ├── columns: x:1(int!null) y:2(int) z:3(float!null) s:4(string)
    60   ├── immutable, side-effects
    61   ├── key: (1)
    62   ├── fd: (1)-->(2-4), (3,4)~~>(1,2)
    63   ├── prune: (1-4)
    64   ├── interesting orderings: (+1) (-4,+3,+1)
    65   ├── scan xyzs
    66   │    ├── columns: x:1(int!null) y:2(int) z:3(float!null) s:4(string)
    67   │    ├── key: (1)
    68   │    ├── fd: (1)-->(2-4), (3,4)~~>(1,2)
    69   │    ├── prune: (1-4)
    70   │    └── interesting orderings: (+1) (-4,+3,+1)
    71   └── subquery [type=int]
    72        └── max1-row
    73             ├── columns: "?column?":5(int!null)
    74             ├── error: "more than one row returned by a subquery used as an expression"
    75             ├── cardinality: [1 - 1]
    76             ├── key: ()
    77             ├── fd: ()-->(5)
    78             └── project
    79                  ├── columns: "?column?":5(int!null)
    80                  ├── cardinality: [1 - 1]
    81                  ├── key: ()
    82                  ├── fd: ()-->(5)
    83                  ├── prune: (5)
    84                  ├── values
    85                  │    ├── cardinality: [1 - 1]
    86                  │    ├── key: ()
    87                  │    └── tuple [type=tuple]
    88                  └── projections
    89                       └── const: 1 [as="?column?":5, type=int]
    90  
    91  build
    92  SELECT * FROM xyzs LIMIT 0
    93  ----
    94  limit
    95   ├── columns: x:1(int!null) y:2(int) z:3(float!null) s:4(string)
    96   ├── cardinality: [0 - 0]
    97   ├── key: ()
    98   ├── fd: ()-->(1-4)
    99   ├── prune: (1-4)
   100   ├── interesting orderings: (+1) (-4,+3,+1)
   101   ├── scan xyzs
   102   │    ├── columns: x:1(int!null) y:2(int) z:3(float!null) s:4(string)
   103   │    ├── key: (1)
   104   │    ├── fd: (1)-->(2-4), (3,4)~~>(1,2)
   105   │    ├── limit hint: 1.00
   106   │    ├── prune: (1-4)
   107   │    └── interesting orderings: (+1) (-4,+3,+1)
   108   └── const: 0 [type=int]
   109  
   110  # Propagate outer columns.
   111  build
   112  SELECT (SELECT x FROM kuv LIMIT y) FROM xyzs
   113  ----
   114  project
   115   ├── columns: x:9(int)
   116   ├── immutable, side-effects
   117   ├── prune: (9)
   118   ├── scan xyzs
   119   │    ├── columns: xyzs.x:1(int!null) y:2(int) z:3(float!null) s:4(string)
   120   │    ├── key: (1)
   121   │    ├── fd: (1)-->(2-4), (3,4)~~>(1,2)
   122   │    ├── prune: (1-4)
   123   │    └── interesting orderings: (+1) (-4,+3,+1)
   124   └── projections
   125        └── subquery [as=x:9, type=int, outer=(1,2), immutable, side-effects, correlated-subquery]
   126             └── max1-row
   127                  ├── columns: x:8(int)
   128                  ├── error: "more than one row returned by a subquery used as an expression"
   129                  ├── outer: (1,2)
   130                  ├── cardinality: [0 - 1]
   131                  ├── immutable, side-effects
   132                  ├── key: ()
   133                  ├── fd: ()-->(8)
   134                  └── limit
   135                       ├── columns: x:8(int)
   136                       ├── outer: (1,2)
   137                       ├── immutable, side-effects
   138                       ├── fd: ()-->(8)
   139                       ├── prune: (8)
   140                       ├── project
   141                       │    ├── columns: x:8(int)
   142                       │    ├── outer: (1)
   143                       │    ├── fd: ()-->(8)
   144                       │    ├── prune: (8)
   145                       │    ├── scan kuv
   146                       │    │    ├── columns: k:5(int!null) u:6(float) v:7(string)
   147                       │    │    ├── key: (5)
   148                       │    │    ├── fd: (5)-->(6,7)
   149                       │    │    ├── prune: (5-7)
   150                       │    │    └── interesting orderings: (+5)
   151                       │    └── projections
   152                       │         └── variable: xyzs.x:1 [as=x:8, type=int, outer=(1)]
   153                       └── variable: y:2 [type=int]
   154  
   155  # Test very high limit (> max uint32).
   156  opt
   157  SELECT s, x FROM xyzs WHERE s='foo' LIMIT 4294967296
   158  ----
   159  scan xyzs@secondary
   160   ├── columns: s:4(string!null) x:1(int!null)
   161   ├── constraint: /-4/3: [/'foo' - /'foo']
   162   ├── limit: 4294967296
   163   ├── key: (1)
   164   ├── fd: ()-->(4)
   165   ├── prune: (1)
   166   └── interesting orderings: (+1) (-4)