3 ms·
Oops, those included per-row timing overhead. Here's the same without that: postgres[24261][1]=# set jit = 1; postgres[24261][1]=# EXPLAIN (ANALYZE, TIM
by anarazel 8y ago
Oops, those included per-row timing overhead. Here's the same without that:
postgres[24261][1]=# set jit = 1;
postgres[24261][1]=# EXPLAIN (ANALYZE, TIMING OFF) SELECT min(tz), sum(data_double), max(data_double) FROM large WHERE tz > '2018-09-23 14:47:30.298302-07';
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ QUERY PLAN │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Finalize Aggregate (cost=1495625.42..1495625.43 rows=1 width=24) (actual rows=1 loops=1) │
│ -> Gather (cost=1495625.20..1495625.41 rows=2 width=24) (actual rows=3 loops=1) │
│ Workers Planned: 2 │
│ Workers Launched: 2 │
│ -> Partial Aggregate (cost=1494625.20..1494625.21 rows=1 width=24) (actual rows=1 loops=3) │
│ -> Parallel Seq Scan on large (cost=0.00..1417317.00 rows=10307760 width=16) (actual rows=33333333 loops=3) │
│ Filter: (tz > '2018-09-23 14:47:30.298302-07'::timestamp with time zone) │
│ Planning Time: 0.121 ms │
│ JIT: │
│ Functions: 8 │
│ Inlining: true │
│ Optimization: true │
│ Execution Time: 2440.328 ms │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
(13 rows)
Time: 2440.891 ms (00:02.441)
postgres[24261][1]=# set jit = 0;
postgres[24261][1]=# EXPLAIN (ANALYZE, TIMING OFF) SELECT min(tz), sum(data_double), max(data_double) FROM large WHERE tz > '2018-09-23 14:47:30.298302-07';
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ QUERY PLAN │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Finalize Aggregate (cost=1495625.42..1495625.43 rows=1 width=24) (actual rows=1 loops=1) │
│ -> Gather (cost=1495625.20..1495625.41 rows=2 width=24) (actual rows=3 loops=1) │
│ Workers Planned: 2 │
│ Workers Launched: 2 │
│ -> Partial Aggregate (cost=1494625.20..1494625.21 rows=1 width=24) (actual rows=1 loops=3) │
│ -> Parallel Seq Scan on large (cost=0.00..1417317.00 rows=10307760 width=16) (actual rows=33333333 loops=3) │
│ Filter: (tz > '2018-09-23 14:47:30.298302-07'::timestamp with time zone) │
│ Planning Time: 0.041 ms │
│ Execution Time: 4140.116 ms │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
(9 rows)
Time: 4140.499 ms (00:04.140)
- anarazel 8y agoFWIW, the non-parallel version yields a profile like: - 25.69% postgres jitted-24373-18.so [.] evalexpr_3_3 - 96.00% evalexpr_3_3 ExecAgg + 2.89% __isnan - 12.15% postgres jitted-24373-16.so [.] evalexpr_3_0 - 99.38% evalexpr_3_0 ExecSeqScan ExecAgg + 0.56% ExecSeqScan - 11.74% postgres postgres [.] heap_getnext 99.83% heap_getnext ExecSeqScan ExecAgg + 9.31% postgres postgres [.] ExecSeqScan + 7.66% postgres libc-2.27.so [.] __memmove_avx_unaligned_erms + 5.61% postgres postgres [.] heapgetpage + 5.36% postgres postgres [.] ExecAgg + 5.35% postgres postgres [.] MemoryContextReset + 4.11% postgres postgres [.] HeapTupleSatisfiesMVCC + 3.53% postgres postgres [.] ExecStoreTuple + 2.55% postgres postgres [.] hash_search_with_hash_value + 1.63% postgres libc-2.27.so [.] __isnan + 1.16% postgres postgres [.] CheckForSerializableConflictOut so it's pretty clear that there's plenty additional work can be done to improve the generated code (it's pretty crappy right now), and that there's potential around improving things due to batching (mainly for increased cache efficiency).