@@ -1331,188 +1331,3 @@ explain (costs off) select * from rparted_by_int2 where a > 100000000000000;
1331
1331
(3 rows)
1332
1332
1333
1333
drop table lp, coll_pruning, rlp, mc3p, mc2p, boolpart, rp, coll_pruning_multi, like_op_noprune, lparted_by_int2, rparted_by_int2;
1334
- -- hash partitioning
1335
- create table hp (a int, b text) partition by hash (a, b);
1336
- create table hp0 partition of hp for values with (modulus 4, remainder 0);
1337
- create table hp3 partition of hp for values with (modulus 4, remainder 3);
1338
- create table hp1 partition of hp for values with (modulus 4, remainder 1);
1339
- create table hp2 partition of hp for values with (modulus 4, remainder 2);
1340
- insert into hp values (null, null);
1341
- insert into hp values (1, null);
1342
- insert into hp values (1, 'xxx');
1343
- insert into hp values (null, 'xxx');
1344
- insert into hp values (10, 'xxx');
1345
- insert into hp values (10, 'yyy');
1346
- select tableoid::regclass, * from hp order by 1;
1347
- tableoid | a | b
1348
- ----------+----+-----
1349
- hp0 | |
1350
- hp0 | 1 |
1351
- hp0 | 1 | xxx
1352
- hp3 | 10 | yyy
1353
- hp1 | | xxx
1354
- hp2 | 10 | xxx
1355
- (6 rows)
1356
-
1357
- -- partial keys won't prune, nor would non-equality conditions
1358
- explain (costs off) select * from hp where a = 1;
1359
- QUERY PLAN
1360
- -------------------------
1361
- Append
1362
- -> Seq Scan on hp0
1363
- Filter: (a = 1)
1364
- -> Seq Scan on hp1
1365
- Filter: (a = 1)
1366
- -> Seq Scan on hp2
1367
- Filter: (a = 1)
1368
- -> Seq Scan on hp3
1369
- Filter: (a = 1)
1370
- (9 rows)
1371
-
1372
- explain (costs off) select * from hp where b = 'xxx';
1373
- QUERY PLAN
1374
- -----------------------------------
1375
- Append
1376
- -> Seq Scan on hp0
1377
- Filter: (b = 'xxx'::text)
1378
- -> Seq Scan on hp1
1379
- Filter: (b = 'xxx'::text)
1380
- -> Seq Scan on hp2
1381
- Filter: (b = 'xxx'::text)
1382
- -> Seq Scan on hp3
1383
- Filter: (b = 'xxx'::text)
1384
- (9 rows)
1385
-
1386
- explain (costs off) select * from hp where a is null;
1387
- QUERY PLAN
1388
- -----------------------------
1389
- Append
1390
- -> Seq Scan on hp0
1391
- Filter: (a IS NULL)
1392
- -> Seq Scan on hp1
1393
- Filter: (a IS NULL)
1394
- -> Seq Scan on hp2
1395
- Filter: (a IS NULL)
1396
- -> Seq Scan on hp3
1397
- Filter: (a IS NULL)
1398
- (9 rows)
1399
-
1400
- explain (costs off) select * from hp where b is null;
1401
- QUERY PLAN
1402
- -----------------------------
1403
- Append
1404
- -> Seq Scan on hp0
1405
- Filter: (b IS NULL)
1406
- -> Seq Scan on hp1
1407
- Filter: (b IS NULL)
1408
- -> Seq Scan on hp2
1409
- Filter: (b IS NULL)
1410
- -> Seq Scan on hp3
1411
- Filter: (b IS NULL)
1412
- (9 rows)
1413
-
1414
- explain (costs off) select * from hp where a < 1 and b = 'xxx';
1415
- QUERY PLAN
1416
- -------------------------------------------------
1417
- Append
1418
- -> Seq Scan on hp0
1419
- Filter: ((a < 1) AND (b = 'xxx'::text))
1420
- -> Seq Scan on hp1
1421
- Filter: ((a < 1) AND (b = 'xxx'::text))
1422
- -> Seq Scan on hp2
1423
- Filter: ((a < 1) AND (b = 'xxx'::text))
1424
- -> Seq Scan on hp3
1425
- Filter: ((a < 1) AND (b = 'xxx'::text))
1426
- (9 rows)
1427
-
1428
- explain (costs off) select * from hp where a <> 1 and b = 'yyy';
1429
- QUERY PLAN
1430
- --------------------------------------------------
1431
- Append
1432
- -> Seq Scan on hp0
1433
- Filter: ((a <> 1) AND (b = 'yyy'::text))
1434
- -> Seq Scan on hp1
1435
- Filter: ((a <> 1) AND (b = 'yyy'::text))
1436
- -> Seq Scan on hp2
1437
- Filter: ((a <> 1) AND (b = 'yyy'::text))
1438
- -> Seq Scan on hp3
1439
- Filter: ((a <> 1) AND (b = 'yyy'::text))
1440
- (9 rows)
1441
-
1442
- -- pruning should work if non-null values are provided for all the keys
1443
- explain (costs off) select * from hp where a is null and b is null;
1444
- QUERY PLAN
1445
- -----------------------------------------------
1446
- Append
1447
- -> Seq Scan on hp0
1448
- Filter: ((a IS NULL) AND (b IS NULL))
1449
- (3 rows)
1450
-
1451
- explain (costs off) select * from hp where a = 1 and b is null;
1452
- QUERY PLAN
1453
- -------------------------------------------
1454
- Append
1455
- -> Seq Scan on hp0
1456
- Filter: ((b IS NULL) AND (a = 1))
1457
- (3 rows)
1458
-
1459
- explain (costs off) select * from hp where a = 1 and b = 'xxx';
1460
- QUERY PLAN
1461
- -------------------------------------------------
1462
- Append
1463
- -> Seq Scan on hp0
1464
- Filter: ((a = 1) AND (b = 'xxx'::text))
1465
- (3 rows)
1466
-
1467
- explain (costs off) select * from hp where a is null and b = 'xxx';
1468
- QUERY PLAN
1469
- -----------------------------------------------------
1470
- Append
1471
- -> Seq Scan on hp1
1472
- Filter: ((a IS NULL) AND (b = 'xxx'::text))
1473
- (3 rows)
1474
-
1475
- explain (costs off) select * from hp where a = 10 and b = 'xxx';
1476
- QUERY PLAN
1477
- --------------------------------------------------
1478
- Append
1479
- -> Seq Scan on hp2
1480
- Filter: ((a = 10) AND (b = 'xxx'::text))
1481
- (3 rows)
1482
-
1483
- explain (costs off) select * from hp where a = 10 and b = 'yyy';
1484
- QUERY PLAN
1485
- --------------------------------------------------
1486
- Append
1487
- -> Seq Scan on hp3
1488
- Filter: ((a = 10) AND (b = 'yyy'::text))
1489
- (3 rows)
1490
-
1491
- explain (costs off) select * from hp where (a = 10 and b = 'yyy') or (a = 10 and b = 'xxx') or (a is null and b is null);
1492
- QUERY PLAN
1493
- -------------------------------------------------------------------------------------------------------------------------
1494
- Append
1495
- -> Seq Scan on hp0
1496
- Filter: (((a = 10) AND (b = 'yyy'::text)) OR ((a = 10) AND (b = 'xxx'::text)) OR ((a IS NULL) AND (b IS NULL)))
1497
- -> Seq Scan on hp2
1498
- Filter: (((a = 10) AND (b = 'yyy'::text)) OR ((a = 10) AND (b = 'xxx'::text)) OR ((a IS NULL) AND (b IS NULL)))
1499
- -> Seq Scan on hp3
1500
- Filter: (((a = 10) AND (b = 'yyy'::text)) OR ((a = 10) AND (b = 'xxx'::text)) OR ((a IS NULL) AND (b IS NULL)))
1501
- (7 rows)
1502
-
1503
- -- hash partitiong pruning doesn't occur with <> operator clauses
1504
- explain (costs off) select * from hp where a <> 1 and b <> 'xxx';
1505
- QUERY PLAN
1506
- ---------------------------------------------------
1507
- Append
1508
- -> Seq Scan on hp0
1509
- Filter: ((a <> 1) AND (b <> 'xxx'::text))
1510
- -> Seq Scan on hp1
1511
- Filter: ((a <> 1) AND (b <> 'xxx'::text))
1512
- -> Seq Scan on hp2
1513
- Filter: ((a <> 1) AND (b <> 'xxx'::text))
1514
- -> Seq Scan on hp3
1515
- Filter: ((a <> 1) AND (b <> 'xxx'::text))
1516
- (9 rows)
1517
-
1518
- drop table hp;
0 commit comments