docs: database efficiency and table recipes#6780
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
Greptile SummaryThis PR adds two new sections to the database query docs ("Writing Efficient Queries" and "Handling NULL Values"), a "Querying Related Rows on Demand" subsection to the relationships page, and several table/pagination UX tips. It also migrates all existing
Confidence Score: 5/5All changes are documentation additions and minor code-sample corrections; no runtime code is modified. Every new code snippet was verified against SQLAlchemy 2 / SQLModel semantics — func.count/group_by, case() positional-tuple syntax, coalesce, expanding=True bindparam, and .debounce(500) event-action chaining are all correct. The User.select() → select(User) migration is consistent across all call sites. No runtime paths are touched. No files require special attention. Important Files Changed
Reviews (6): Last reviewed commit: "docs: address review — select() idiom, r..." | Re-trigger Greptile |
FarhanAliRaza
left a comment
There was a problem hiding this comment.
rx.Model is deprecated. do we want to add new docs using deprecated feature ? We can use new code example maybe.
|
Thanks @FarhanAliRaza — addressed this round.
While in here I also fixed two accuracy issues in the new content: "single indexed query" claim (relationships.md, 8b41c43): Reserved keyword in raw SQL (queries.md, 2e6bb28): the expanding |
Writing Efficient Queries (SQL-side aggregation, N+1 avoidance with .in_() and expanding bindparams, select-what-the-UI-needs), NULL handling with func.coalesce, on-demand related-row queries, per-table pagination state guidance, and debounced table search. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Reword opener to "Databases are generally much better...". - Put the efficient N+1 example above the inefficient one. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
9ad026a to
ac49909
Compare
- Use select(Model) instead of Model.select() throughout queries.md and relationships.md; add the sqlmodel select import to the relationships example that has explicit imports. - Move the raw-SQL "expanding bind parameter / never string-format" pointer into an `md alert info` block so the agent surfaces it. - Recommend and link ComponentState for building reusable paginated tables. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Fifth batch of upstreaming Reflex Build's AI-builder knowledge base. Database/table techniques, translated into the docs' own ORM idiom:
func.count/group_by, conditional aggregation withcase), avoid N+1 with.in_()(plus a raw-SQLexpanding=Truebindparam alternative), return only what the UI needs (column selection, LIMIT, load-once options, don't cache whole tables in per-user state); new "Handling NULL Values" section (func.coalesce, Python-side guards)overflow_xcontainer guidance, per-table pagination state (reset offset on filter change), debounced search inputs (.debounce(500)) with a per-keystroke-query warningFlexgen-environment rules (raw-SQL-only mandates, schema conventions) were deliberately not upstreamed. Pre-commit clean.
🤖 Generated with Claude Code