forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitdc3f9bc
committed
Micro-optimize JSONTYPE_NUMERIC code path in json.c.
This commit does the following:* In datum_to_json_internal(), the call to IsValidJsonNumber() is replaced with simplified validation code. This avoids an extra call to strlen() in this path, and it avoids validating the entire string (which is okay since we know we're dealing with a numeric data type's output).* In datum_to_json_internal(), the call to escape_json() in the JSONTYPE_NUMERIC path is replaced with code that just surrounds the string with quotes. In passing, some other nearby calls to appendStringInfo() have been replaced with similar code to avoid unnecessary calls to vsnprintf().* In composite_to_json(), the length of the separator is now determined at compile time to avoid unnecessary calls to strlen().On my machine, this speeds up a benchmark for the proposed COPY TO(FORMAT json) command with many integers by upwards of 20%. Thereare likely other code paths that could be given a similartreatment, but that is left as a future exercise.Reviewed-by: Jeff Davis, Tom Lane, David Rowley, John NaylorDiscussion:https://postgr.es/m/20231207231251.GB3359478%40nathanxps131 parent867dd2d commitdc3f9bc
1 file changed
+29
-8
lines changedLines changed: 29 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
220 | 220 |
| |
221 | 221 |
| |
222 | 222 |
| |
223 |
| - | |
224 |
| - | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
225 | 227 |
| |
226 |
| - | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
227 | 232 |
| |
228 | 233 |
| |
229 |
| - | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
230 | 239 |
| |
231 | 240 |
| |
232 | 241 |
| |
233 | 242 |
| |
234 | 243 |
| |
235 | 244 |
| |
236 | 245 |
| |
237 |
| - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
238 | 249 |
| |
239 | 250 |
| |
240 | 251 |
| |
241 | 252 |
| |
242 | 253 |
| |
243 | 254 |
| |
244 | 255 |
| |
245 |
| - | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
246 | 259 |
| |
247 | 260 |
| |
248 | 261 |
| |
249 | 262 |
| |
250 | 263 |
| |
251 | 264 |
| |
252 | 265 |
| |
253 |
| - | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
254 | 269 |
| |
255 | 270 |
| |
256 | 271 |
| |
| |||
503 | 518 |
| |
504 | 519 |
| |
505 | 520 |
| |
| 521 | + | |
506 | 522 |
| |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
507 | 527 |
| |
| 528 | + | |
508 | 529 |
| |
509 | 530 |
| |
510 | 531 |
| |
| |||
533 | 554 |
| |
534 | 555 |
| |
535 | 556 |
| |
536 |
| - | |
| 557 | + | |
537 | 558 |
| |
538 | 559 |
| |
539 | 560 |
| |
|
0 commit comments
Comments
(0)