forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitefdcca5
committed
Make better use of the new List implementation in a couple of places
In nodeAppend.c and nodeMergeAppend.c there were some foreach loops whichlooped over the list of subplans and only performed any work if thesubplan index was found in a Bitmapset. With the old linked listimplementation of List, this form made sense as accessing the Nth listelement was O(N). However, thanks to1cff1b9 we now have array-basedlists, so accessing the Nth element has become O(1).Here we make the most of the O(1) lookups and just loop over the setmembers of the Bitmapset with bms_next_member(). This performs slightlybetter when a small number of the list items are in the Bitmapset. Microbenchmarks show that when the Bitmapset contains all or most of the listitems then the new code is ever so slightly slower. In practice, the costis so small that it's drowned out by various other things such as lockingthe relations belonging to each subplan, etc.The primary goal here is to leave better code examples around which benefitbetter from the new list implementation.Reviewed-by: Tom LaneDiscussion:https://postgr.es/m/CAKJS1f8ZcsLVgkF4wOfRyMYTcPgLFiUAOedFC+U2vK_aFZk-BA@mail.gmail.com1 parent23bccc8 commitefdcca5
2 files changed
+15
-24
lines changedLines changed: 10 additions & 15 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
107 | 107 |
| |
108 | 108 |
| |
109 | 109 |
| |
110 |
| - | |
111 | 110 |
| |
112 | 111 |
| |
113 | 112 |
| |
| |||
211 | 210 |
| |
212 | 211 |
| |
213 | 212 |
| |
214 |
| - | |
| 213 | + | |
215 | 214 |
| |
216 |
| - | |
| 215 | + | |
| 216 | + | |
217 | 217 |
| |
218 |
| - | |
219 |
| - | |
220 |
| - | |
| 218 | + | |
221 | 219 |
| |
222 |
| - | |
223 |
| - | |
224 |
| - | |
225 |
| - | |
226 |
| - | |
227 |
| - | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
228 | 225 |
| |
229 |
| - | |
230 |
| - | |
231 |
| - | |
| 226 | + | |
232 | 227 |
| |
233 | 228 |
| |
234 | 229 |
| |
|
Lines changed: 5 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
70 | 70 |
| |
71 | 71 |
| |
72 | 72 |
| |
73 |
| - | |
74 | 73 |
| |
75 | 74 |
| |
76 | 75 |
| |
| |||
177 | 176 |
| |
178 | 177 |
| |
179 | 178 |
| |
180 |
| - | |
181 |
| - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
182 | 182 |
| |
183 |
| - | |
184 |
| - | |
185 |
| - | |
| 183 | + | |
186 | 184 |
| |
187 |
| - | |
188 |
| - | |
189 |
| - | |
| 185 | + | |
190 | 186 |
| |
191 | 187 |
| |
192 | 188 |
| |
|
0 commit comments
Comments
(0)