Edmund Horner <ejr...@gmail.com> writes: > My patch uses the same path type and executor for all extractable tidquals.
> This worked pretty well, but I am finding it difficult to reimplement it in > the new tidpath.c code. I didn't like that approach to begin with, and would suggest that you go over to using a separate path type and executor node. I don't think the amount of commonality for the two cases is all that large, and doing it as you had it required some ugly ad-hoc conventions about the semantics of the tidquals list. Where I think this should go is that the tidquals list still has OR semantics in the existing path type, but you use AND semantics in the new path type, so that "ctid > ? AND ctid < ?" is just represented as an implicit-AND list of two simple RestrictInfos. Now admittedly, this wouldn't give us an efficient way to execute queries with conditions like "WHERE ctid = X OR (ctid > Y AND ctid < Z)", but I find myself quite unable to get excited about supporting that. I see no reason for the new code to worry about any cases more complex than one or two TID inequalities at top level of the restriction list. > In the query information given to the path generator, there is no existing > RestrictInfo relating to the whole expression "ctid > ? AND ctid < ?". I > am still learning about RestrictInfos, but my understanding is it doesn't > make sense to have a RestrictInfo for an AND clause, anyway; you're > supposed to have them for the sub-expressions of it. FWIW, the actual data structure for cases like that is that there's a RestrictInfo for the whole clause ctid = X OR (ctid > Y AND ctid < Z), and if you look into its "orclause" field, you will find RestrictInfos attached to the primitive clauses ctid = X, ctid > Y, ctid < Z. (The old code in tidpath.c didn't know that, because it'd never been rewritten since RestrictInfos were invented.) However, I think this new code should not worry about OR cases at all, but just pull out top-level TID comparison clauses. > And it doesn't seem a good idea to try to create new RestrictInfos in the > path generation just to pass the tidquals back to plan creation. No, you should avoid that. There are places that assume there's only one RestrictInfo for any given original clause (or sub-clause). regards, tom lane