In this article
Specify null placement and null-group selection separately; arranging null values at the end does not make a greater-than predicate include them.
Decide where unscored documents belong
A source list is ordered by an optional review score. Some documents have no score yet. PostgREST’s ordering reference supports nullsfirst and nullslast alongside direction. Choose the policy deliberately: an unscored source might belong after reviewed sources, regardless of whether scored values ascend or descend. Null placement is part of the API’s displayed ordering rather than an automatic interpretation of what missing review means.
Keep direction and null placement independent
PostgreSQL’s sorting guide places nulls last by default for ascending order and first for descending order. Changing direction can therefore move the unscored group even when the client did not explicitly change its business policy. An explicit setting such as score.desc.nullslast documents the intended combination. Preserve the same null policy when changing page size or adding secondary ordering fields.
Do not turn placement into ordinary comparison
The comparison reference defines ordinary comparisons involving null as unknown, rather than true or false. Placing null after every known score does not make score greater than the last known value for filter purposes. A continuation filter containing only an ordinary greater-than condition can omit the null group despite an ordering that visually places it later. Use dedicated null predicates when the requested subset includes those rows.
Define the transition between groups
For a client traversing valued rows and then unscored rows, define when it enters the null group and how it orders records inside that group. If null comes first, define the opposite transition. Carry enough continuation state to distinguish the group instead of treating a missing score as a substitute numeric boundary. Task contracts identify whether every source must remain reachable, including sources that have not received a review score.
Inspect selection separately from presentation
Compare the explicit ordering with the filters selecting each page, then inspect representative unscored sources. Tool observations should retain the group transition and actual predicates. A response can be correctly sorted while excluding rows the client expected its continuation to reach. This distinction directs the remedy toward selection logic rather than repeatedly changing null placement or assuming that missing scores were silently converted into ordinary sortable numbers.
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.