docs(ai): document hidden counts in application queries

This commit is contained in:
Andras Bacsai
2026-10-29 00:00:06 +01:00
parent 3607abf7eb
commit f778942630
+3
View File
@@ -155,5 +155,8 @@
## Validate input safely
- In PCRE, `$` also matches before a final `\n`. In validation regexes, use `\z` or reject control characters first, or a trailing newline passes.
## Application queries carry hidden counts
- `Application` has a global scope `withRelations` that adds two `withCount` subqueries and `applications.*`, also to `pluck('id')` and eager loads. For ID lookups and lean eager loads, call `withoutGlobalScope('withRelations')`.
## Measure database reads end to end
- On PostgreSQL 15, `EXPLAIN (ANALYZE, BUFFERS)` does not detoast or send the selected columns, so a wide `jsonb`/`json`/`text` column does not show in it. Time the full fetch (`psql \timing` with `-o /dev/null`, or PDO `fetchAll`) as well before you blame or rule out an index.