Skip to content

Commit 0ea89f0

Browse files
committed
Page datastore queries that fetched all applications
ListApplications for piped, ListApplications for web, and the application lookup in CreateDeploymentChain ran one query with no limit and returned every matching row. A project with thousands of applications pays for all of them on every sync even though the RPC responses have no cursor field and cannot page. These now fetch 100 rows at a time and combine the pages before responding. Paging by cursor needs a fixed sort order, so the queries sort by Id. ListEvents also pages now. It defaults to newest first when a request leaves the order unset, which previously errored on the second page. (Also repairs the ListEvents pagination test to use the correct mock). Added the composite indexes these query shapes need to firestoreindexensurer; Firestore does not create them automatically. Fixes #7051 Signed-off-by: srinivasr <sriniv4sreddy@gmail.com>
1 parent 25b4ba2 commit 0ea89f0

8 files changed

Lines changed: 737 additions & 8 deletions

File tree

pkg/app/ops/firestoreindexensurer/indexes.json

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,114 @@
11
[
2+
{
3+
"collectionGroup": "Application",
4+
"queryScope": "COLLECTION",
5+
"fields": [
6+
{
7+
"fieldPath": "ProjectId",
8+
"order": "ASCENDING",
9+
"arrayConfig": ""
10+
},
11+
{
12+
"fieldPath": "PipedId",
13+
"order": "ASCENDING",
14+
"arrayConfig": ""
15+
},
16+
{
17+
"fieldPath": "Disabled",
18+
"order": "ASCENDING",
19+
"arrayConfig": ""
20+
},
21+
{
22+
"fieldPath": "Id",
23+
"order": "ASCENDING",
24+
"arrayConfig": ""
25+
}
26+
]
27+
},
28+
{
29+
"collectionGroup": "Application",
30+
"queryScope": "COLLECTION",
31+
"fields": [
32+
{
33+
"fieldPath": "ProjectId",
34+
"order": "ASCENDING",
35+
"arrayConfig": ""
36+
},
37+
{
38+
"fieldPath": "Id",
39+
"order": "ASCENDING",
40+
"arrayConfig": ""
41+
}
42+
]
43+
},
44+
{
45+
"collectionGroup": "Application",
46+
"queryScope": "COLLECTION",
47+
"fields": [
48+
{
49+
"fieldPath": "ProjectId",
50+
"order": "ASCENDING",
51+
"arrayConfig": ""
52+
},
53+
{
54+
"fieldPath": "Name",
55+
"order": "ASCENDING",
56+
"arrayConfig": ""
57+
},
58+
{
59+
"fieldPath": "Id",
60+
"order": "ASCENDING",
61+
"arrayConfig": ""
62+
}
63+
]
64+
},
65+
{
66+
"collectionGroup": "Application",
67+
"queryScope": "COLLECTION",
68+
"fields": [
69+
{
70+
"fieldPath": "ProjectId",
71+
"order": "ASCENDING",
72+
"arrayConfig": ""
73+
},
74+
{
75+
"fieldPath": "Kind",
76+
"order": "ASCENDING",
77+
"arrayConfig": ""
78+
},
79+
{
80+
"fieldPath": "Id",
81+
"order": "ASCENDING",
82+
"arrayConfig": ""
83+
}
84+
]
85+
},
86+
{
87+
"collectionGroup": "Application",
88+
"queryScope": "COLLECTION",
89+
"fields": [
90+
{
91+
"fieldPath": "ProjectId",
92+
"order": "ASCENDING",
93+
"arrayConfig": ""
94+
},
95+
{
96+
"fieldPath": "Name",
97+
"order": "ASCENDING",
98+
"arrayConfig": ""
99+
},
100+
{
101+
"fieldPath": "Kind",
102+
"order": "ASCENDING",
103+
"arrayConfig": ""
104+
},
105+
{
106+
"fieldPath": "Id",
107+
"order": "ASCENDING",
108+
"arrayConfig": ""
109+
}
110+
]
111+
},
2112
{
3113
"collectionGroup": "Application",
4114
"queryScope": "COLLECTION",
@@ -141,6 +251,27 @@
141251
}
142252
]
143253
},
254+
{
255+
"collectionGroup": "Application",
256+
"queryScope": "COLLECTION",
257+
"fields": [
258+
{
259+
"fieldPath": "ProjectId",
260+
"order": "ASCENDING",
261+
"arrayConfig": ""
262+
},
263+
{
264+
"fieldPath": "Disabled",
265+
"order": "ASCENDING",
266+
"arrayConfig": ""
267+
},
268+
{
269+
"fieldPath": "Id",
270+
"order": "ASCENDING",
271+
"arrayConfig": ""
272+
}
273+
]
274+
},
144275
{
145276
"collectionGroup": "Command",
146277
"queryScope": "COLLECTION",
@@ -550,6 +681,53 @@
550681
}
551682
]
552683
},
684+
{
685+
"collectionGroup": "Event",
686+
"queryScope": "COLLECTION",
687+
"fields": [
688+
{
689+
"fieldPath": "ProjectId",
690+
"order": "ASCENDING",
691+
"arrayConfig": ""
692+
},
693+
{
694+
"fieldPath": "CreatedAt",
695+
"order": "DESCENDING",
696+
"arrayConfig": ""
697+
},
698+
{
699+
"fieldPath": "Id",
700+
"order": "ASCENDING",
701+
"arrayConfig": ""
702+
}
703+
]
704+
},
705+
{
706+
"collectionGroup": "Event",
707+
"queryScope": "COLLECTION",
708+
"fields": [
709+
{
710+
"fieldPath": "ProjectId",
711+
"order": "ASCENDING",
712+
"arrayConfig": ""
713+
},
714+
{
715+
"fieldPath": "Status",
716+
"order": "ASCENDING",
717+
"arrayConfig": ""
718+
},
719+
{
720+
"fieldPath": "CreatedAt",
721+
"order": "ASCENDING",
722+
"arrayConfig": ""
723+
},
724+
{
725+
"fieldPath": "Id",
726+
"order": "ASCENDING",
727+
"arrayConfig": ""
728+
}
729+
]
730+
},
553731
{
554732
"collectionGroup": "DeploymentChain",
555733
"queryScope": "COLLECTION",

0 commit comments

Comments
 (0)