forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit5d56d07
committed
Optimize tuplestore usage for WITH RECURSIVE CTEs
nodeRecursiveunion.c makes use of two tuplestores and, until now, woulddelete and recreate one of these tuplestores after every recursiveiteration.Here we adjust that behavior and instead reuse one of the existingtuplestores and just empty it of all tuples using tuplestore_clear().This saves some free/malloc roundtrips and has shown a 25-30% performanceimprovement for queries that perform very little work between recursiveiterations.This also paves the way to add some EXPLAIN ANALYZE telemetry output forrecursive common table expressions, similar to what was done in1eff827and95d6e9a. Previously calling tuplestore_end() would have causedthe maximum storage space used to be lost.Reviewed-by: Tatsuo IshiiDiscussion:https://postgr.es/m/CAApHDvr9yW0YRiK8A2J7nvyT8g17YzbSfOviEWrghazKZbHbig@mail.gmail.com1 parent8a6e85b commit5d56d07
1 file changed
+13
-6
lines changedLines changed: 13 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
115 | 115 |
| |
116 | 116 |
| |
117 | 117 |
| |
| 118 | + | |
| 119 | + | |
118 | 120 |
| |
119 | 121 |
| |
120 | 122 |
| |
121 | 123 |
| |
122 |
| - | |
123 |
| - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
124 | 132 |
| |
125 |
| - | |
| 133 | + | |
126 | 134 |
| |
| 135 | + | |
127 | 136 |
| |
128 |
| - | |
129 |
| - | |
130 |
| - | |
| 137 | + | |
131 | 138 |
| |
132 | 139 |
| |
133 | 140 |
| |
|
0 commit comments
Comments
(0)