github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/opt/memo/testdata/logprops/insert (about) 1 exec-ddl 2 CREATE TABLE abcde ( 3 a INT NOT NULL, 4 b INT, 5 c INT NOT NULL DEFAULT (10), 6 d INT AS (b + c + 1) STORED, 7 "e:write-only" INT 8 ) 9 ---- 10 11 exec-ddl 12 CREATE TABLE xyz ( 13 x TEXT PRIMARY KEY, 14 y INT8 NOT NULL, 15 z FLOAT8 16 ) 17 ---- 18 19 # Properties with no RETURNING clause. 20 build 21 INSERT INTO abcde (a, b) SELECT y, y FROM xyz ORDER BY y, z LIMIT 10 22 ---- 23 insert abcde 24 ├── columns: <none> 25 ├── insert-mapping: 26 │ ├── y:8 => a:1 27 │ ├── y:8 => b:2 28 │ ├── column10:10 => c:3 29 │ ├── column13:13 => d:4 30 │ ├── column11:11 => rowid:5 31 │ └── column12:12 => e:6 32 ├── cardinality: [0 - 0] 33 ├── volatile, side-effects, mutations 34 └── project 35 ├── columns: column13:13(int!null) y:8(int!null) column10:10(int!null) column11:11(int) column12:12(int) 36 ├── cardinality: [0 - 10] 37 ├── volatile, side-effects 38 ├── fd: ()-->(10,12), (8)-->(13) 39 ├── prune: (8,10-13) 40 ├── interesting orderings: (+8) 41 ├── project 42 │ ├── columns: column10:10(int!null) column11:11(int) column12:12(int) y:8(int!null) 43 │ ├── cardinality: [0 - 10] 44 │ ├── volatile, side-effects 45 │ ├── fd: ()-->(10,12) 46 │ ├── prune: (8,10-12) 47 │ ├── interesting orderings: (+8) 48 │ ├── limit 49 │ │ ├── columns: y:8(int!null) z:9(float) 50 │ │ ├── internal-ordering: +8,+9 51 │ │ ├── cardinality: [0 - 10] 52 │ │ ├── interesting orderings: (+8,+9) 53 │ │ ├── sort 54 │ │ │ ├── columns: y:8(int!null) z:9(float) 55 │ │ │ ├── ordering: +8,+9 56 │ │ │ ├── limit hint: 10.00 57 │ │ │ ├── prune: (8,9) 58 │ │ │ └── project 59 │ │ │ ├── columns: y:8(int!null) z:9(float) 60 │ │ │ ├── prune: (8,9) 61 │ │ │ └── scan xyz 62 │ │ │ ├── columns: x:7(string!null) y:8(int!null) z:9(float) 63 │ │ │ ├── key: (7) 64 │ │ │ ├── fd: (7)-->(8,9) 65 │ │ │ ├── prune: (7-9) 66 │ │ │ └── interesting orderings: (+7) 67 │ │ └── const: 10 [type=int] 68 │ └── projections 69 │ ├── const: 10 [as=column10:10, type=int] 70 │ ├── function: unique_rowid [as=column11:11, type=int, volatile, side-effects] 71 │ └── cast: INT8 [as=column12:12, type=int] 72 │ └── null [type=unknown] 73 └── projections 74 └── plus [as=column13:13, type=int, outer=(8,10)] 75 ├── plus [type=int] 76 │ ├── variable: y:8 [type=int] 77 │ └── variable: column10:10 [type=int] 78 └── const: 1 [type=int] 79 80 # Properties with RETURNING clause. 81 build 82 INSERT INTO abcde (a, b) SELECT y, y FROM xyz ORDER BY y, z LIMIT 10 RETURNING * 83 ---- 84 project 85 ├── columns: a:1(int!null) b:2(int!null) c:3(int!null) d:4(int!null) 86 ├── cardinality: [0 - 10] 87 ├── volatile, side-effects, mutations 88 ├── fd: ()-->(3), (1)==(2), (2)==(1), (1)-->(4) 89 ├── prune: (1-4) 90 └── insert abcde 91 ├── columns: a:1(int!null) b:2(int!null) c:3(int!null) d:4(int!null) rowid:5(int!null) 92 ├── insert-mapping: 93 │ ├── y:8 => a:1 94 │ ├── y:8 => b:2 95 │ ├── column10:10 => c:3 96 │ ├── column13:13 => d:4 97 │ ├── column11:11 => rowid:5 98 │ └── column12:12 => e:6 99 ├── cardinality: [0 - 10] 100 ├── volatile, side-effects, mutations 101 ├── fd: ()-->(3), (1)==(2), (2)==(1), (1)-->(4) 102 └── project 103 ├── columns: column13:13(int!null) y:8(int!null) column10:10(int!null) column11:11(int) column12:12(int) 104 ├── cardinality: [0 - 10] 105 ├── volatile, side-effects 106 ├── fd: ()-->(10,12), (8)-->(13) 107 ├── prune: (8,10-13) 108 ├── interesting orderings: (+8) 109 ├── project 110 │ ├── columns: column10:10(int!null) column11:11(int) column12:12(int) y:8(int!null) 111 │ ├── cardinality: [0 - 10] 112 │ ├── volatile, side-effects 113 │ ├── fd: ()-->(10,12) 114 │ ├── prune: (8,10-12) 115 │ ├── interesting orderings: (+8) 116 │ ├── limit 117 │ │ ├── columns: y:8(int!null) z:9(float) 118 │ │ ├── internal-ordering: +8,+9 119 │ │ ├── cardinality: [0 - 10] 120 │ │ ├── interesting orderings: (+8,+9) 121 │ │ ├── sort 122 │ │ │ ├── columns: y:8(int!null) z:9(float) 123 │ │ │ ├── ordering: +8,+9 124 │ │ │ ├── limit hint: 10.00 125 │ │ │ ├── prune: (8,9) 126 │ │ │ └── project 127 │ │ │ ├── columns: y:8(int!null) z:9(float) 128 │ │ │ ├── prune: (8,9) 129 │ │ │ └── scan xyz 130 │ │ │ ├── columns: x:7(string!null) y:8(int!null) z:9(float) 131 │ │ │ ├── key: (7) 132 │ │ │ ├── fd: (7)-->(8,9) 133 │ │ │ ├── prune: (7-9) 134 │ │ │ └── interesting orderings: (+7) 135 │ │ └── const: 10 [type=int] 136 │ └── projections 137 │ ├── const: 10 [as=column10:10, type=int] 138 │ ├── function: unique_rowid [as=column11:11, type=int, volatile, side-effects] 139 │ └── cast: INT8 [as=column12:12, type=int] 140 │ └── null [type=unknown] 141 └── projections 142 └── plus [as=column13:13, type=int, outer=(8,10)] 143 ├── plus [type=int] 144 │ ├── variable: y:8 [type=int] 145 │ └── variable: column10:10 [type=int] 146 └── const: 1 [type=int] 147 148 # Properties with RETURNING clause. 149 build 150 INSERT INTO abcde (a, b) SELECT y, y FROM xyz ORDER BY y, z RETURNING * 151 ---- 152 project 153 ├── columns: a:1(int!null) b:2(int!null) c:3(int!null) d:4(int!null) 154 ├── volatile, side-effects, mutations 155 ├── fd: ()-->(3), (1)==(2), (2)==(1), (1)-->(4) 156 ├── prune: (1-4) 157 └── insert abcde 158 ├── columns: a:1(int!null) b:2(int!null) c:3(int!null) d:4(int!null) rowid:5(int!null) 159 ├── insert-mapping: 160 │ ├── y:8 => a:1 161 │ ├── y:8 => b:2 162 │ ├── column10:10 => c:3 163 │ ├── column13:13 => d:4 164 │ ├── column11:11 => rowid:5 165 │ └── column12:12 => e:6 166 ├── volatile, side-effects, mutations 167 ├── fd: ()-->(3), (1)==(2), (2)==(1), (1)-->(4) 168 └── project 169 ├── columns: column13:13(int!null) y:8(int!null) column10:10(int!null) column11:11(int) column12:12(int) 170 ├── volatile, side-effects 171 ├── fd: ()-->(10,12), (8)-->(13) 172 ├── prune: (8,10-13) 173 ├── project 174 │ ├── columns: column10:10(int!null) column11:11(int) column12:12(int) y:8(int!null) 175 │ ├── volatile, side-effects 176 │ ├── fd: ()-->(10,12) 177 │ ├── prune: (8,10-12) 178 │ ├── project 179 │ │ ├── columns: y:8(int!null) z:9(float) 180 │ │ ├── prune: (8,9) 181 │ │ └── scan xyz 182 │ │ ├── columns: x:7(string!null) y:8(int!null) z:9(float) 183 │ │ ├── key: (7) 184 │ │ ├── fd: (7)-->(8,9) 185 │ │ ├── prune: (7-9) 186 │ │ └── interesting orderings: (+7) 187 │ └── projections 188 │ ├── const: 10 [as=column10:10, type=int] 189 │ ├── function: unique_rowid [as=column11:11, type=int, volatile, side-effects] 190 │ └── cast: INT8 [as=column12:12, type=int] 191 │ └── null [type=unknown] 192 └── projections 193 └── plus [as=column13:13, type=int, outer=(8,10)] 194 ├── plus [type=int] 195 │ ├── variable: y:8 [type=int] 196 │ └── variable: column10:10 [type=int] 197 └── const: 1 [type=int] 198 199 # Input is cardinality 1 VALUES expression. 200 build 201 INSERT INTO abcde (a, b) (VALUES (1, 2)) RETURNING *, rowid; 202 ---- 203 insert abcde 204 ├── columns: a:1(int!null) b:2(int!null) c:3(int!null) d:4(int!null) rowid:5(int!null) 205 ├── insert-mapping: 206 │ ├── column1:7 => a:1 207 │ ├── column2:8 => b:2 208 │ ├── column9:9 => c:3 209 │ ├── column12:12 => d:4 210 │ ├── column10:10 => rowid:5 211 │ └── column11:11 => e:6 212 ├── cardinality: [1 - 1] 213 ├── volatile, side-effects, mutations 214 ├── key: () 215 ├── fd: ()-->(1-5) 216 └── project 217 ├── columns: column12:12(int!null) column1:7(int!null) column2:8(int!null) column9:9(int!null) column10:10(int) column11:11(int) 218 ├── cardinality: [1 - 1] 219 ├── volatile, side-effects 220 ├── key: () 221 ├── fd: ()-->(7-12) 222 ├── prune: (7-12) 223 ├── project 224 │ ├── columns: column9:9(int!null) column10:10(int) column11:11(int) column1:7(int!null) column2:8(int!null) 225 │ ├── cardinality: [1 - 1] 226 │ ├── volatile, side-effects 227 │ ├── key: () 228 │ ├── fd: ()-->(7-11) 229 │ ├── prune: (7-11) 230 │ ├── values 231 │ │ ├── columns: column1:7(int!null) column2:8(int!null) 232 │ │ ├── cardinality: [1 - 1] 233 │ │ ├── key: () 234 │ │ ├── fd: ()-->(7,8) 235 │ │ ├── prune: (7,8) 236 │ │ └── tuple [type=tuple{int, int}] 237 │ │ ├── const: 1 [type=int] 238 │ │ └── const: 2 [type=int] 239 │ └── projections 240 │ ├── const: 10 [as=column9:9, type=int] 241 │ ├── function: unique_rowid [as=column10:10, type=int, volatile, side-effects] 242 │ └── cast: INT8 [as=column11:11, type=int] 243 │ └── null [type=unknown] 244 └── projections 245 └── plus [as=column12:12, type=int, outer=(8,9)] 246 ├── plus [type=int] 247 │ ├── variable: column2:8 [type=int] 248 │ └── variable: column9:9 [type=int] 249 └── const: 1 [type=int] 250 251 # Filter FD set. 252 build 253 INSERT INTO abcde (a, b) SELECT y, (z+1)::int FROM xyz WHERE y=1 RETURNING a, c; 254 ---- 255 project 256 ├── columns: a:1(int!null) c:3(int!null) 257 ├── volatile, side-effects, mutations 258 ├── fd: ()-->(1,3) 259 ├── prune: (1,3) 260 └── insert abcde 261 ├── columns: a:1(int!null) b:2(int) c:3(int!null) d:4(int) rowid:5(int!null) 262 ├── insert-mapping: 263 │ ├── y:8 => a:1 264 │ ├── int8:10 => b:2 265 │ ├── column11:11 => c:3 266 │ ├── column14:14 => d:4 267 │ ├── column12:12 => rowid:5 268 │ └── column13:13 => e:6 269 ├── volatile, side-effects, mutations 270 ├── fd: ()-->(1,3), (2)-->(4) 271 └── project 272 ├── columns: column14:14(int) y:8(int!null) int8:10(int) column11:11(int!null) column12:12(int) column13:13(int) 273 ├── volatile, side-effects 274 ├── fd: ()-->(8,11,13), (10)-->(14) 275 ├── prune: (8,10-14) 276 ├── project 277 │ ├── columns: column11:11(int!null) column12:12(int) column13:13(int) y:8(int!null) int8:10(int) 278 │ ├── volatile, side-effects 279 │ ├── fd: ()-->(8,11,13) 280 │ ├── prune: (8,10-13) 281 │ ├── project 282 │ │ ├── columns: int8:10(int) y:8(int!null) 283 │ │ ├── fd: ()-->(8) 284 │ │ ├── prune: (8,10) 285 │ │ ├── select 286 │ │ │ ├── columns: x:7(string!null) y:8(int!null) z:9(float) 287 │ │ │ ├── key: (7) 288 │ │ │ ├── fd: ()-->(8), (7)-->(9) 289 │ │ │ ├── prune: (7,9) 290 │ │ │ ├── interesting orderings: (+7) 291 │ │ │ ├── scan xyz 292 │ │ │ │ ├── columns: x:7(string!null) y:8(int!null) z:9(float) 293 │ │ │ │ ├── key: (7) 294 │ │ │ │ ├── fd: (7)-->(8,9) 295 │ │ │ │ ├── prune: (7-9) 296 │ │ │ │ └── interesting orderings: (+7) 297 │ │ │ └── filters 298 │ │ │ └── eq [type=bool, outer=(8), constraints=(/8: [/1 - /1]; tight), fd=()-->(8)] 299 │ │ │ ├── variable: y:8 [type=int] 300 │ │ │ └── const: 1 [type=int] 301 │ │ └── projections 302 │ │ └── cast: INT8 [as=int8:10, type=int, outer=(9)] 303 │ │ └── plus [type=float] 304 │ │ ├── variable: z:9 [type=float] 305 │ │ └── const: 1.0 [type=float] 306 │ └── projections 307 │ ├── const: 10 [as=column11:11, type=int] 308 │ ├── function: unique_rowid [as=column12:12, type=int, volatile, side-effects] 309 │ └── cast: INT8 [as=column13:13, type=int] 310 │ └── null [type=unknown] 311 └── projections 312 └── plus [as=column14:14, type=int, outer=(10,11)] 313 ├── plus [type=int] 314 │ ├── variable: int8:10 [type=int] 315 │ └── variable: column11:11 [type=int] 316 └── const: 1 [type=int]