forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit73b06cf
committed
Avoid taking a new snapshot for an immutable simple expression in plpgsql.
We already used this optimization if the plpgsql function is read-only.But it seems okay to do it even in a read-write function, if theexpression contains only immutable functions/operators. There wouldonly be a change of behavior if an "immutable" called function dependson seeing database updates made during the current plpgsql function.That's enough of a violation of the promise of immutability that anyonewho complains won't have much of a case.The benefits are significant --- for simple cases like while i < 10000000 loop i := i + 1; end loop;I see net performance improvements around 45%. Of course, real-worldcases won't get that much faster, but it ought to be noticeable.At the very least, this removes much of the performance penalty thatused to exist for forgetting to mark a plpgsql function non-volatile.Konstantin Knizhnik, reviewed by Pavel Stehule, cosmetic changes by meDiscussion:https://postgr.es/m/ed9da20e-01aa-d04b-d085-e6c16b14b9d7@postgrespro.ru1 parentf67b173 commit73b06cf
2 files changed
+16
-5
lines changedLines changed: 15 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6079 | 6079 |
| |
6080 | 6080 |
| |
6081 | 6081 |
| |
| 6082 | + | |
6082 | 6083 |
| |
6083 | 6084 |
| |
6084 | 6085 |
| |
| |||
6150 | 6151 |
| |
6151 | 6152 |
| |
6152 | 6153 |
| |
6153 |
| - | |
6154 |
| - | |
6155 |
| - | |
| 6154 | + | |
| 6155 | + | |
| 6156 | + | |
| 6157 | + | |
| 6158 | + | |
| 6159 | + | |
| 6160 | + | |
| 6161 | + | |
| 6162 | + | |
6156 | 6163 |
| |
6157 | 6164 |
| |
6158 |
| - | |
| 6165 | + | |
| 6166 | + | |
6159 | 6167 |
| |
6160 | 6168 |
| |
6161 | 6169 |
| |
| |||
6180 | 6188 |
| |
6181 | 6189 |
| |
6182 | 6190 |
| |
6183 |
| - | |
| 6191 | + | |
6184 | 6192 |
| |
6185 | 6193 |
| |
6186 | 6194 |
| |
| |||
8051 | 8059 |
| |
8052 | 8060 |
| |
8053 | 8061 |
| |
| 8062 | + | |
| 8063 | + | |
8054 | 8064 |
| |
8055 | 8065 |
| |
8056 | 8066 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
234 | 234 |
| |
235 | 235 |
| |
236 | 236 |
| |
| 237 | + | |
237 | 238 |
| |
238 | 239 |
| |
239 | 240 |
| |
|
0 commit comments
Comments
(0)