forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitb5810de
committed
Reduce memory consumption for multi-statement query strings.
Previously, exec_simple_query always ran parse analysis, rewrite, andplanning in MessageContext, allowing all the data generated therebyto persist until the end of processing of the whole query string.That's fine for single-command strings, but if a client sends manycommands in a single simple-Query message, this strategy could resultin annoying memory bloat, as complained of by Andreas Seltenreich.To fix, create a child context to do this work in, and reclaim itafter each command. But we only do so for parsetrees that are notlast in their query string. That avoids adding any memory managementoverhead for the typical case of a single-command string. Memoryallocated for the last parsetree would be freed immediately afterfinishing the command string anyway.Similarly, adjust extension.c's execute_sql_string() to reclaim memoryafter each command. In that usage, multi-command strings are the norm,so it's a bit surprising that no one has yet complained of bloat ---especially since the bloat extended to whatever data ProcessUtilityexecution might leak.Amit Langote, reviewed by Julien RouhaudDiscussion:https://postgr.es/m/87ftp6l2qr.fsf@credativ.de1 parent909a7b6 commitb5810de
2 files changed
+41
-5
lines changedLines changed: 16 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
717 | 717 |
| |
718 | 718 |
| |
719 | 719 |
| |
| 720 | + | |
| 721 | + | |
720 | 722 |
| |
721 | 723 |
| |
722 | 724 |
| |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
723 | 735 |
| |
724 | 736 |
| |
725 | 737 |
| |
| |||
772 | 784 |
| |
773 | 785 |
| |
774 | 786 |
| |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
775 | 791 |
| |
776 | 792 |
| |
777 | 793 |
| |
|
Lines changed: 25 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1070 | 1070 |
| |
1071 | 1071 |
| |
1072 | 1072 |
| |
| 1073 | + | |
1073 | 1074 |
| |
1074 | 1075 |
| |
1075 | 1076 |
| |
| |||
1132 | 1133 |
| |
1133 | 1134 |
| |
1134 | 1135 |
| |
1135 |
| - | |
1136 |
| - | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
1137 | 1144 |
| |
1138 |
| - | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
1139 | 1155 |
| |
1140 | 1156 |
| |
1141 | 1157 |
| |
| |||
1160 | 1176 |
| |
1161 | 1177 |
| |
1162 | 1178 |
| |
1163 |
| - | |
1164 |
| - | |
| 1179 | + | |
| 1180 | + | |
1165 | 1181 |
| |
1166 | 1182 |
| |
1167 | 1183 |
| |
| |||
1263 | 1279 |
| |
1264 | 1280 |
| |
1265 | 1281 |
| |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
1266 | 1286 |
| |
1267 | 1287 |
| |
1268 | 1288 |
| |
|
0 commit comments
Comments
(0)