forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit0a87ddf
committed
Cache the result of converting now() to a struct pg_tm.
SQL operations such as CURRENT_DATE, CURRENT_TIME, LOCALTIME, andconversion of "now" in a datetime input string have to obtain thetransaction start timestamp ("now()") as a broken-down struct pg_tm.This is a remarkably expensive conversion, and since now() does notchange intra-transaction, it doesn't really need to be done more thanonce per transaction. Introducing a simple cache provides visiblespeedups in queries that compute these values many times, for exampleinsertion of many rows that use a default value of CURRENT_DATE.Peter Smith, with a bit of kibitzing by meDiscussion:https://postgr.es/m/CAHut+Pu89TWjq530V2gY5O6SWi=OEJMQ_VHMt8bdZB_9JFna5A@mail.gmail.com1 parente21cbb4 commit0a87ddf
2 files changed
+80
-36
lines changedLines changed: 24 additions & 25 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
299 | 299 |
| |
300 | 300 |
| |
301 | 301 |
| |
302 |
| - | |
303 |
| - | |
304 |
| - | |
305 |
| - | |
306 |
| - | |
| 302 | + | |
307 | 303 |
| |
308 |
| - | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
309 | 308 |
| |
310 |
| - | |
311 |
| - | |
312 |
| - | |
313 |
| - | |
| 309 | + | |
314 | 310 |
| |
315 |
| - | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
316 | 327 |
| |
317 | 328 |
| |
318 | 329 |
| |
| |||
322 | 333 |
| |
323 | 334 |
| |
324 | 335 |
| |
325 |
| - | |
326 | 336 |
| |
327 | 337 |
| |
328 | 338 |
| |
329 | 339 |
| |
330 | 340 |
| |
331 |
| - | |
332 |
| - | |
333 |
| - | |
334 |
| - | |
335 |
| - | |
336 |
| - | |
| 341 | + | |
337 | 342 |
| |
338 | 343 |
| |
339 | 344 |
| |
| |||
348 | 353 |
| |
349 | 354 |
| |
350 | 355 |
| |
351 |
| - | |
352 | 356 |
| |
353 | 357 |
| |
354 | 358 |
| |
355 | 359 |
| |
356 | 360 |
| |
357 |
| - | |
358 |
| - | |
359 |
| - | |
360 |
| - | |
361 |
| - | |
362 |
| - | |
| 361 | + | |
363 | 362 |
| |
364 | 363 |
| |
365 | 364 |
| |
|
Lines changed: 56 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
339 | 339 |
| |
340 | 340 |
| |
341 | 341 |
| |
342 |
| - | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
343 | 347 |
| |
344 | 348 |
| |
345 | 349 |
| |
346 | 350 |
| |
347 |
| - | |
348 | 351 |
| |
349 | 352 |
| |
350 |
| - | |
351 |
| - | |
352 |
| - | |
| 353 | + | |
353 | 354 |
| |
354 | 355 |
| |
355 | 356 |
| |
356 | 357 |
| |
357 | 358 |
| |
358 | 359 |
| |
359 |
| - | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
360 | 368 |
| |
361 | 369 |
| |
362 | 370 |
| |
363 | 371 |
| |
364 |
| - | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
365 | 411 |
| |
366 |
| - | |
367 |
| - | |
368 |
| - | |
| 412 | + | |
| 413 | + | |
369 | 414 |
| |
370 |
| - | |
| 415 | + | |
371 | 416 |
| |
372 | 417 |
| |
373 | 418 |
| |
|
0 commit comments
Comments
(0)