@@ -1632,30 +1632,36 @@ appendonly_endscan(TableScanDesc scan)
1632
1632
pfree (aoscan );
1633
1633
}
1634
1634
1635
- /* ----------------
1636
- * appendonly_getnextslot - retrieve next tuple in scan
1637
- * ----------------
1638
- */
1639
- bool
1640
- appendonly_getnextslot (TableScanDesc scan , ScanDirection direction , TupleTableSlot * slot )
1635
+
1636
+ static pg_attribute_hot_inline bool
1637
+ appendonly_getnextslot_noqual (AppendOnlyScanDesc aoscan , ScanDirection direction , TupleTableSlot * slot )
1641
1638
{
1642
- AppendOnlyScanDesc aoscan = (AppendOnlyScanDesc ) scan ;
1643
1639
while (appendonlygettup (aoscan , direction , aoscan -> rs_base .rs_nkeys , aoscan -> aos_key , slot ))
1644
1640
{
1641
+ pgstat_count_heap_getnext (aoscan -> aos_rd );
1642
+ return true;
1643
+ }
1644
+ if (slot )
1645
+ ExecClearTuple (slot );
1646
+ return false;
1647
+ }
1648
+
1649
+ static bool
1650
+ appendonly_getnextslot_withqual (AppendOnlyScanDesc aoscan , ScanDirection direction , TupleTableSlot * slot )
1651
+ {
1652
+ while (appendonlygettup (aoscan , direction , aoscan -> rs_base .rs_nkeys , aoscan -> aos_key , slot ))
1653
+ {
1654
+ Assert (aoscan -> aos_pushdown_qual );
1655
+ /*
1656
+ * place the current tuple into the expr context
1657
+ */
1658
+ aoscan -> aos_pushdown_econtext -> ecxt_scantuple = slot ;
1645
1659
/* predicate pushdown test */
1646
- if (aoscan -> aos_pushdown_qual )
1660
+ if (! ExecQual ( aoscan -> aos_pushdown_qual , aoscan -> aos_pushdown_econtext ) )
1647
1661
{
1648
- /*
1649
- * place the current tuple into the expr context
1650
- */
1651
- aoscan -> aos_pushdown_econtext -> ecxt_scantuple = slot ;
1652
-
1653
- if (!ExecQual (aoscan -> aos_pushdown_qual , aoscan -> aos_pushdown_econtext ))
1654
- {
1655
- /* Tuple fails qual, so free per-tuple memory and try again. */
1656
- ResetExprContext (aoscan -> aos_pushdown_econtext );
1657
- continue ;
1658
- }
1662
+ /* Tuple fails qual, so free per-tuple memory and try again. */
1663
+ ResetExprContext (aoscan -> aos_pushdown_econtext );
1664
+ continue ;
1659
1665
}
1660
1666
1661
1667
pgstat_count_heap_getnext (aoscan -> aos_rd );
@@ -1669,6 +1675,25 @@ appendonly_getnextslot(TableScanDesc scan, ScanDirection direction, TupleTableSl
1669
1675
return false;
1670
1676
}
1671
1677
1678
+ /* ----------------
1679
+ * appendonly_getnextslot - retrieve next tuple in scan
1680
+ * ----------------
1681
+ */
1682
+ pg_attribute_hot bool
1683
+ appendonly_getnextslot (TableScanDesc scan , ScanDirection direction , TupleTableSlot * slot )
1684
+ {
1685
+ AppendOnlyScanDesc aoscan = (AppendOnlyScanDesc ) scan ;
1686
+ /*
1687
+ * [0] = noqual, [1] = withqual
1688
+ */
1689
+ static bool (* const getnext_impl [2 ])(AppendOnlyScanDesc , ScanDirection , TupleTableSlot * ) = {
1690
+ appendonly_getnextslot_noqual ,
1691
+ appendonly_getnextslot_withqual
1692
+ };
1693
+
1694
+ return getnext_impl [!!aoscan -> aos_pushdown_qual ](aoscan , direction , slot );
1695
+ }
1696
+
1672
1697
uint32
1673
1698
appendonly_scan_flags (Relation relation )
1674
1699
{
0 commit comments