2018-05-17 11:32 GMT+02:00 Pavel Stehule <pavel.steh...@gmail.com>:

> Hi
>
> just for curiosity - I tested simple script
>
> postgres=# do
> $$
> declare s bigint = 0;
> begin
>   for i in 1..1000000000 loop
>     s := s + i;
>   end loop;
>   raise notice '%', s;
> end;
> $$;
>
> to see a overhead of some components
>
>    5,72%  plpgsql.so                             [.] exec_assign_value
>    5,59%  postgres                               [.] GetSnapshotData
>    4,94%  plpgsql.so                             [.] exec_eval_simple_expr
>    4,84%  postgres                               [.] AllocSetAlloc
>    3,61%  postgres                               [.]
> ResourceOwnerForgetPlanCacheRef
>    2,95%  postgres                               [.] choose_custom_plan
>    2,94%  postgres                               [.] GetUserId
>    2,92%  postgres                               [.] GetCachedPlan
>    2,87%  postgres                               [.] LWLockAttemptLock
>    2,85%  postgres                               [.] memset@plt
>    2,76%  postgres                               [.] LWLockRelease
>    2,70%  postgres                               [.] AllocSetFree
>    2,42%  plpgsql.so                             [.] assign_simple_var
>    2,36%  postgres                               [.] ExecInterpExpr
>    2,35%  postgres                               [.] PopActiveSnapshot
>    2,27%  postgres                               [.]
> OverrideSearchPathMatchesCurrent
>    2,22%  plpgsql.so                             [.]
> plpgsql_param_eval_var
>    2,21%  plpgsql.so                             [.] exec_stmt
>    1,89%  libc-2.27.so                           [.]
> __memset_sse2_unaligned_erms
>    1,75%  postgres                               [.] PushActiveSnapshot
>    1,74%  postgres                               [.] AcquireExecutorLocks
>    1,67%  postgres                               [.] CopySnapshot
>    1,64%  postgres                               [.] CheckCachedPlan
>    1,56%  postgres                               [.] RevalidateCachedQuery
>    1,55%  postgres                               [.] MemoryContextAlloc
>    1,53%  postgres                               [.] pfree
>    1,50%  postgres                               [.] ResourceArrayRemove
>    1,43%  postgres                               [.] LWLockAcquire
>    1,40%  postgres                               [.]
> SPI_plan_get_cached_plan
>
>
maybe we need some new kind of function, that doesn't requires snapshots,
user info, locks - and the plan can be stored directly instead using plan
cache.

Hard to believe, what necessary be done before we want to calculate two
numbers.

Regards

Pavel


> Regards
>
> Pavel
>

Reply via email to