I noticed that the Record Layer planner performs a full range scan where it isn’t required.
A record of type R with primary key k was queried using the query below.
Note that k is a primary key exclusively for record type R and no other record type, yet the planner scans all records instead of scanning only those record types that have k as their primary key.
Also, this issue is similar to this one yet I’m adding this here to highlight the fact that the issue persists even when recordType() is not concatenated in the primary key.
Interestingly, that issue suggests that the plan that should be produced for that scan is actually an error:
Note that if one includes the record type key in the sort predicate, then it will do a full scan. If one omits the record type key (which it should be able to), then it throws an error.
Thanks for your response. I think this discrepancy stems from the fact that in one case the primary key has recordType() concatenated in it and in the other it doesn’t.
When the primary key has recordType() concatenated, it throws an error when recordType() is omitted in the sort expression as it isn’t able to map the sort expression to any index/primary key.