@@ -1165,239 +1165,6 @@ select tableoid::regclass, * from idxpart order by a;
1165
1165
(8 rows)
1166
1166
1167
1167
drop table idxpart;
1168
- -- test fastpath mechanism for index insertion
1169
- create table fastpath (a int, b text, c numeric);
1170
- create unique index fpindex1 on fastpath(a);
1171
- insert into fastpath values (1, 'b1', 100.00);
1172
- insert into fastpath values (1, 'b1', 100.00); -- unique key check
1173
- ERROR: duplicate key value violates unique constraint "fpindex1"
1174
- DETAIL: Key (a)=(1) already exists.
1175
- truncate fastpath;
1176
- insert into fastpath select generate_series(1,10000), 'b', 100;
1177
- -- vacuum the table so as to improve chances of index-only scans. we can't
1178
- -- guarantee if index-only scans will be picked up in all cases or not, but
1179
- -- that fuzziness actually helps the test.
1180
- vacuum fastpath;
1181
- set enable_seqscan to false;
1182
- set enable_bitmapscan to false;
1183
- select sum(a) from fastpath where a = 6456;
1184
- sum
1185
- ------
1186
- 6456
1187
- (1 row)
1188
-
1189
- select sum(a) from fastpath where a >= 5000 and a < 5700;
1190
- sum
1191
- ---------
1192
- 3744650
1193
- (1 row)
1194
-
1195
- -- drop the only index on the table and compute hashes for
1196
- -- a few queries which orders the results in various different ways.
1197
- drop index fpindex1;
1198
- truncate fastpath;
1199
- insert into fastpath select y.x, 'b' || (y.x/10)::text, 100 from (select generate_series(1,10000) as x) y;
1200
- select md5(string_agg(a::text, b order by a, b asc)) from fastpath
1201
- where a >= 1000 and a < 2000 and b > 'b1' and b < 'b3';
1202
- md5
1203
- ----------------------------------
1204
- 2ca216010a558a52d7df12f76dfc77ab
1205
- (1 row)
1206
-
1207
- select md5(string_agg(a::text, b order by a desc, b desc)) from fastpath
1208
- where a >= 1000 and a < 2000 and b > 'b1' and b < 'b3';
1209
- md5
1210
- ----------------------------------
1211
- 6167a852b3e0679886b84a5405b5b53d
1212
- (1 row)
1213
-
1214
- select md5(string_agg(a::text, b order by b, a desc)) from fastpath
1215
- where a >= 1000 and a < 2000 and b > 'b1' and b < 'b3';
1216
- md5
1217
- ----------------------------------
1218
- dfcf2bd5e5fea8397d47b2fd14618d31
1219
- (1 row)
1220
-
1221
- select md5(string_agg(a::text, b order by b, a asc)) from fastpath
1222
- where a >= 1000 and a < 2000 and b > 'b1' and b < 'b3';
1223
- md5
1224
- ----------------------------------
1225
- 2ca216010a558a52d7df12f76dfc77ab
1226
- (1 row)
1227
-
1228
- -- now create a multi-column index with both column asc
1229
- create index fpindex2 on fastpath(a, b);
1230
- truncate fastpath;
1231
- insert into fastpath select y.x, 'b' || (y.x/10)::text, 100 from (select generate_series(1,10000) as x) y;
1232
- -- again, vacuum here either forces index-only scans or creates fuzziness
1233
- vacuum fastpath;
1234
- select md5(string_agg(a::text, b order by a, b asc)) from fastpath
1235
- where a >= 1000 and a < 2000 and b > 'b1' and b < 'b3';
1236
- md5
1237
- ----------------------------------
1238
- 2ca216010a558a52d7df12f76dfc77ab
1239
- (1 row)
1240
-
1241
- select md5(string_agg(a::text, b order by a desc, b desc)) from fastpath
1242
- where a >= 1000 and a < 2000 and b > 'b1' and b < 'b3';
1243
- md5
1244
- ----------------------------------
1245
- 6167a852b3e0679886b84a5405b5b53d
1246
- (1 row)
1247
-
1248
- select md5(string_agg(a::text, b order by b, a desc)) from fastpath
1249
- where a >= 1000 and a < 2000 and b > 'b1' and b < 'b3';
1250
- md5
1251
- ----------------------------------
1252
- dfcf2bd5e5fea8397d47b2fd14618d31
1253
- (1 row)
1254
-
1255
- select md5(string_agg(a::text, b order by b, a asc)) from fastpath
1256
- where a >= 1000 and a < 2000 and b > 'b1' and b < 'b3';
1257
- md5
1258
- ----------------------------------
1259
- 2ca216010a558a52d7df12f76dfc77ab
1260
- (1 row)
1261
-
1262
- -- same queries with a different kind of index now. the final result must not
1263
- -- change irrespective of what kind of index we have.
1264
- drop index fpindex2;
1265
- create index fpindex3 on fastpath(a desc, b asc);
1266
- truncate fastpath;
1267
- insert into fastpath select y.x, 'b' || (y.x/10)::text, 100 from (select generate_series(1,10000) as x) y;
1268
- vacuum fastpath;
1269
- select md5(string_agg(a::text, b order by a, b asc)) from fastpath
1270
- where a >= 1000 and a < 2000 and b > 'b1' and b < 'b3';
1271
- md5
1272
- ----------------------------------
1273
- 2ca216010a558a52d7df12f76dfc77ab
1274
- (1 row)
1275
-
1276
- select md5(string_agg(a::text, b order by a desc, b desc)) from fastpath
1277
- where a >= 1000 and a < 2000 and b > 'b1' and b < 'b3';
1278
- md5
1279
- ----------------------------------
1280
- 6167a852b3e0679886b84a5405b5b53d
1281
- (1 row)
1282
-
1283
- select md5(string_agg(a::text, b order by b, a desc)) from fastpath
1284
- where a >= 1000 and a < 2000 and b > 'b1' and b < 'b3';
1285
- md5
1286
- ----------------------------------
1287
- dfcf2bd5e5fea8397d47b2fd14618d31
1288
- (1 row)
1289
-
1290
- select md5(string_agg(a::text, b order by b, a asc)) from fastpath
1291
- where a >= 1000 and a < 2000 and b > 'b1' and b < 'b3';
1292
- md5
1293
- ----------------------------------
1294
- 2ca216010a558a52d7df12f76dfc77ab
1295
- (1 row)
1296
-
1297
- -- repeat again
1298
- drop index fpindex3;
1299
- create index fpindex4 on fastpath(a asc, b desc);
1300
- truncate fastpath;
1301
- insert into fastpath select y.x, 'b' || (y.x/10)::text, 100 from (select generate_series(1,10000) as x) y;
1302
- vacuum fastpath;
1303
- select md5(string_agg(a::text, b order by a, b asc)) from fastpath
1304
- where a >= 1000 and a < 2000 and b > 'b1' and b < 'b3';
1305
- md5
1306
- ----------------------------------
1307
- 2ca216010a558a52d7df12f76dfc77ab
1308
- (1 row)
1309
-
1310
- select md5(string_agg(a::text, b order by a desc, b desc)) from fastpath
1311
- where a >= 1000 and a < 2000 and b > 'b1' and b < 'b3';
1312
- md5
1313
- ----------------------------------
1314
- 6167a852b3e0679886b84a5405b5b53d
1315
- (1 row)
1316
-
1317
- select md5(string_agg(a::text, b order by b, a desc)) from fastpath
1318
- where a >= 1000 and a < 2000 and b > 'b1' and b < 'b3';
1319
- md5
1320
- ----------------------------------
1321
- dfcf2bd5e5fea8397d47b2fd14618d31
1322
- (1 row)
1323
-
1324
- select md5(string_agg(a::text, b order by b, a asc)) from fastpath
1325
- where a >= 1000 and a < 2000 and b > 'b1' and b < 'b3';
1326
- md5
1327
- ----------------------------------
1328
- 2ca216010a558a52d7df12f76dfc77ab
1329
- (1 row)
1330
-
1331
- -- and again, this time indexing by (b, a). Note that column "b" has non-unique
1332
- -- values.
1333
- drop index fpindex4;
1334
- create index fpindex5 on fastpath(b asc, a desc);
1335
- truncate fastpath;
1336
- insert into fastpath select y.x, 'b' || (y.x/10)::text, 100 from (select generate_series(1,10000) as x) y;
1337
- vacuum fastpath;
1338
- select md5(string_agg(a::text, b order by a, b asc)) from fastpath
1339
- where a >= 1000 and a < 2000 and b > 'b1' and b < 'b3';
1340
- md5
1341
- ----------------------------------
1342
- 2ca216010a558a52d7df12f76dfc77ab
1343
- (1 row)
1344
-
1345
- select md5(string_agg(a::text, b order by a desc, b desc)) from fastpath
1346
- where a >= 1000 and a < 2000 and b > 'b1' and b < 'b3';
1347
- md5
1348
- ----------------------------------
1349
- 6167a852b3e0679886b84a5405b5b53d
1350
- (1 row)
1351
-
1352
- select md5(string_agg(a::text, b order by b, a desc)) from fastpath
1353
- where a >= 1000 and a < 2000 and b > 'b1' and b < 'b3';
1354
- md5
1355
- ----------------------------------
1356
- dfcf2bd5e5fea8397d47b2fd14618d31
1357
- (1 row)
1358
-
1359
- select md5(string_agg(a::text, b order by b, a asc)) from fastpath
1360
- where a >= 1000 and a < 2000 and b > 'b1' and b < 'b3';
1361
- md5
1362
- ----------------------------------
1363
- 2ca216010a558a52d7df12f76dfc77ab
1364
- (1 row)
1365
-
1366
- -- one last time
1367
- drop index fpindex5;
1368
- create index fpindex6 on fastpath(b desc, a desc);
1369
- truncate fastpath;
1370
- insert into fastpath select y.x, 'b' || (y.x/10)::text, 100 from (select generate_series(1,10000) as x) y;
1371
- vacuum fastpath;
1372
- select md5(string_agg(a::text, b order by a, b asc)) from fastpath
1373
- where a >= 1000 and a < 2000 and b > 'b1' and b < 'b3';
1374
- md5
1375
- ----------------------------------
1376
- 2ca216010a558a52d7df12f76dfc77ab
1377
- (1 row)
1378
-
1379
- select md5(string_agg(a::text, b order by a desc, b desc)) from fastpath
1380
- where a >= 1000 and a < 2000 and b > 'b1' and b < 'b3';
1381
- md5
1382
- ----------------------------------
1383
- 6167a852b3e0679886b84a5405b5b53d
1384
- (1 row)
1385
-
1386
- select md5(string_agg(a::text, b order by b, a desc)) from fastpath
1387
- where a >= 1000 and a < 2000 and b > 'b1' and b < 'b3';
1388
- md5
1389
- ----------------------------------
1390
- dfcf2bd5e5fea8397d47b2fd14618d31
1391
- (1 row)
1392
-
1393
- select md5(string_agg(a::text, b order by b, a asc)) from fastpath
1394
- where a >= 1000 and a < 2000 and b > 'b1' and b < 'b3';
1395
- md5
1396
- ----------------------------------
1397
- 2ca216010a558a52d7df12f76dfc77ab
1398
- (1 row)
1399
-
1400
- drop table fastpath;
1401
1168
-- intentionally leave some objects around
1402
1169
create table idxpart (a int) partition by range (a);
1403
1170
create table idxpart1 partition of idxpart for values from (0) to (100);
0 commit comments