Hi all, I have managed to split my changes into 4 patches:
v3-0001-Add-selectivity-and-nullness-estimates-for-the-ItemP.patch v3-0002-Support-range-quals-in-Tid-Scan.patch v3-0003-Support-backward-scans-over-restricted-ranges-in-hea.patch v3-0004-Tid-Scan-results-are-ordered.patch (1) is basically independent, and usefully improves estimates for ctid quals. (2) is the main patch, adding basic range scan support to TidPath and TidScan. (3) is a small change to properly support backward scans over a restricted range in heapam.c, and is needed for (4). (4) adds Backward Tid Scans, and adds path keys to Tid Paths so that the planner doesn't have to add a sort for certain queries. I have tried to apply David's suggestions. In (1), I've included the offset part of a CTID constant in the selectivity calculation. I've not included "allvisfrac" in the calculation; I'm not sure it's worth it as it would only affect the offset part. I have tried to use iseq to differentiate between <=,>= versus <,>, but I'm not sure I've got this right. I am also not entirely sure it's worth it; the changes are already an improvement over the current behaviour of using hardcoded selectivity constants. In (2), the planner now picks up a greater variety of TID quals, including AND-clauses with arbitrary children instead of the original lower bound/upper bound pair. These are resolved in the executor into a list of ranges to scan. (3) is the same code, but I've added a couple of comments to explain the change. (4) is basically the same pathkey/direction code as before (but as a separate patch). I hope the separation will make it easier to review. Item (2) is still quite big, but a third of it is tests. Cheers. Edmund
v3-0002-Support-range-quals-in-Tid-Scan.patch
Description: Binary data
v3-0001-Add-selectivity-and-nullness-estimates-for-the-ItemP.patch
Description: Binary data
v3-0003-Support-backward-scans-over-restricted-ranges-in-hea.patch
Description: Binary data
v3-0004-Tid-Scan-results-are-ordered.patch
Description: Binary data