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.
RecordQuery.newBuilder() .setRecordType("R") .setSort(Key.Expressions.field("k"),true) .build();
The query plan was then found to be:
Query Plan: Scan(<,>) | [R]
However, a more optimal plan would be:
Query Plan: [IS R]
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.