review: Reduce palloc's in numeric operations - Mailing list pgsql-hackers
From | Pavel Stehule |
---|---|
Subject | review: Reduce palloc's in numeric operations |
Date | |
Msg-id | CAFj8pRCLpJzBGEL4rZjEtgjD8esiKXtN9wzsnfA6_ESpvnFP5w@mail.gmail.com Whole thread Raw |
Responses |
Re: review: Reduce palloc's in numeric operations
|
List | pgsql-hackers |
Hello all I tested this patch and I can confirm, so this patch can increase speed about 16-22% (depends on IO waits, load type). I tested real query (anonymyzed) SELECT SUM(COALESCE((a * b * c * (d + ((1 -(d)) * (1 -(e))))),0)) m1 FROM tab; -- patched 4493 26.5591 postgres slot_deform_tuple 1327 7.8442 postgres AllocSetAlloc 1313 7.7614 postgres ExecMakeFunctionResultNoSets 1105 6.5319 postgres set_var_from_num_nocopy 924 5.4620 postgres make_result 637 3.7654 postgres mul_var 635 3.7536 postgres numeric_mul 560 3.3103 postgres MemoryContextAlloc 405 2.3940 postgres AllocSetFree 389 2.2995 postgres ExecEvalScalarVarFast 332 1.9625 postgres slot_getsomeattrs 322 1.9034 postgres numeric_add 313 1.8502 postgres add_abs 304 1.7970 postgres pfree 238 1.4069 postgres slot_getattr 216 1.2768 postgres numeric_sub 200 1.1822 postgres heap_tuple_untoast_attr 183 1.0818 postgres strip_var 180 1.0640 postgres ExecEvalConst 173 1.0226 postgres alloc_var 172 1.0167 postgres check_stack_depth -- origin 4419 22.8325 postgres slot_deform_tuple 2041 10.5456 postgres AllocSetAlloc 1248 6.4483 postgres set_var_from_num 1186 6.1279 postgres ExecMakeFunctionResultNoSets 886 4.5779 postgres MemoryContextAlloc 856 4.4229 postgres make_result 757 3.9113 postgres numeric_mul 731 3.7770 postgres AllocSetFree 625 3.2293 postgres mul_var 601 3.1053 postgres alloc_var 545 2.8160 postgres pfree 503 2.5989 postgres free_var 458 2.3664 postgres slot_getsomeattrs 378 1.9531 postgres numeric_add 360 1.8601 postgres add_abs 336 1.7361 postgres ExecEvalScalarVarFast 266 1.3744 postgres slot_getattr 221 1.1419 postgres numeric_sub Review: 1) this patch was clearly applied and compilation was without warning 2) regress tests - All 133 tests passed. 4) don't see any memory leaks there (verified by following code) CREATE OR REPLACE FUNCTION public.fx(_m integer)RETURNS voidLANGUAGE plpgsql AS $function$ declare m numeric = 10; n numeric = 20022.222; r numeric; begin for i in 1.._m loop r := m * n; end loop; end; $function$ postgres=# select fx(10000000);fx ---- (1 row) Time: 5312.623 ms --- original ( 4798.103 ms -- patched 10% speedup) 5) it respect PostgreSQL's coding standards 6) we would to accept this patch - it can carry 10% speedup calculations with numerics. Regards Pavel Stehule
pgsql-hackers by date: