perf(queries): index migration + tz-aware days (closes #208) - #209
Draft
carvalab wants to merge 1 commit into
Draft
perf(queries): index migration + tz-aware days (closes #208)#209carvalab wants to merge 1 commit into
carvalab wants to merge 1 commit into
Conversation
carvalab
marked this pull request as draft
August 1, 2026 02:52
carvalab
force-pushed
the
find-issue-performance
branch
2 times, most recently
from
August 1, 2026 21:37
947a9fe to
26300e9
Compare
…oses FreeOpenSourcePOS#208) Database performance for 100k+ order installs: - Migration v44 (renumbered past upstream v40-43): adds 11 indexes and normalizes every legacy ISO timestamp to the DB's UTC space form, including order_items.voided_at and the cloud/support outbox tables. - now() emits space-form timestamps; parseDbTimestamp/utcDayBounds/utcTodayDate centralize UTC parsing and day-range queries. - Query rewrites: KDS/kitchen active-orders UNION instead of OR EXISTS, customers CTE instead of 4 correlated subqueries, batched items/addons hydration (list + GET /orders/:id), range filters on new indexes, default page-size caps, orders cursor. - Space-form bounds for whatsapp rate limit, cloud retries, KDS pairing expiry, voided-item cutoffs; UTC-aware timestamp display in the frontend (useFormatDate, printer format-date, product images, whatsapp timeline, tax config panel).
carvalab
force-pushed
the
find-issue-performance
branch
from
August 3, 2026 02:43
43ccd58 to
c1ddebf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #208.
I built a synthetic 1-year database (109,500 orders at 300/day, plus a 3-year at 328,500) and timed every hot query on this branch against the same dataset the issue measured. Everything below was measured, not estimated.
What this PR does:
Same 1-year dataset, before and after, milliseconds (3-run best):
At 3 years, the customers list drops from a frozen ~174s to roughly 30ms. The other queries scale the same way since they're index- or batch-driven now.
Follow-ups not in this PR: