RunQuery: add SkipTotalRowCount so MaxRows does not run the whole query a second time for its count
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- graphql, sql, typescript
Direzione di ricerca
Start with RunViewParams.SkipTotalRowCount to see the existing pattern, then read GenericDatabaseProvider.ts around the parallel data/count block (~L7838) and countAdhocRows (~L8074). Trace RunQueryParams through the saved-query and ad-hoc ExecuteFromSpec paths, and the GraphQL inputs GetQueryData, GetQueryDataByName and the ad-hoc test resolvers. Done means both paths page without issuing CountSQL when the flag is true, pass the flag from GraphQL, and preserve current behavior by default.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
RunView can skip its total-row count (SkipTotalRowCount, in RunViewParams since 6.2.2), but RunQuery cannot. Whenever a RunQuery call sets MaxRows, the provider pages the query and runs the whole query a second time as a COUNT(*), in parallel with the page:
- saved queries:
GenericDatabaseProvider.ts~L7838 onnext("Execute data + count queries in parallel"), the same code in 6.1.6 and 6.2.2; - ad-hoc SQL (
ExecuteFromSpec/RunQuerywithSQL):countAdhocRows(rendered.PagingResult?.CountSQL ...)~L8074.
So MaxRows limits the rows returned but roughly doubles the database work for a heavy query, and there is no way to opt out. A caller that only wants a few rows (a sample, a smoke test, a preview) has to choose between:
- No
MaxRows: the full result is fetched and serialized. A saved query over an 8M-row table made MJAPI fail withRangeError: Invalid string lengthinRunQueryResolver.GetQueryData(JSON.stringify). MaxRows: the full query runs twice. An aggregate that takes 13-49 s on its own hits a 30 srequestTimeoutbecause the parallelCOUNT(*)competes with it on the same database.
We hit both from Skip on a client database (Azure SQL serverless, 4 vCores): Skip runs every query it saves once, with test parameters, to confirm it executes and to cache sample rows.
Proposal
Add SkipTotalRowCount?: boolean to RunQueryParams, mirroring RunViewParams:
- when
truewithMaxRows, page the query (OFFSET ... FETCH/LIMIT) but do not run theCountSQL; returnTotalRowCountas the rows returned (or leave it undefined), asRunViewdoes; - apply it to both the saved-query path and the ad-hoc SQL path;
- expose it on the GraphQL query inputs (
GetQueryData,GetQueryDataByName, and the ad-hoc test resolvers) so remote callers can pass it; - default
false, so existing callers that rely onTotalRowCountkeep it.
Related
- #6000 (RunView with
MaxRows: 1andTotalRowCount): the RunView side of the same trade-off.
- Lingua principale
- TSQL
- Stelle
- 32
- Fork
- 7
- Merge medio
- 1g 16h
- PR unite (30g)
- 504
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di MemberJunction/MJ
-
DBAutoDoc: export --state-file writes SQL Server SQL for a PostgreSQL database, ignoring --providerAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
MemberJunction/MJ#7094 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 85/100
MemberJunction/MJ#6971 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
MemberJunction/MJ#6947 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
MemberJunction/MJ#6800 ·
I maintainer di solito rispondono entro 1 giorno
-
Convention: saved-query discoverability follows Status — Approved is canon, Pending is a draftAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
MemberJunction/MJ#6746 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di MemberJunction/MJ
Issue simili
-
HXsetdir strdup leakAperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 82/100
-
funding: failure logs print `<nil>` error and zero channel IDForse già presa @litbot-9000 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
lightningnetwork/lnd#11676 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
Fei2411/DeepSeek-Bot#2891 ·
-
factory:subtask
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
I maintainer di solito rispondono entro 1 giorno