WebAPI Load Tests PostgreSQL Function

Setup

create function public.test_func_v1(
    _records int,
    _text_param text,
    _int_param int,
    _ts_param timestamp,
    _bool_param bool
) 
returns table(
    id1 int, 
    foo1 text, 
    bar1 text, 
    datetime1 timestamp, 
    id2 int, 
    foo2 text, 
    bar2 text, 
    datetime2 timestamp,
    long_foo_bar text, 
    is_foobar bool
)
stable
language sql
as
$$
select
    i + _int_param as id1,
    'foo' || '_' || _text_param || '_' || i::text as foo1,
    'bar' || i::text as bar1,
    (_ts_param::date) + (i::text || ' days')::interval as datetime1,
    i+1 + _int_param as id2,
    'foo' || '_' || _text_param || '_' || (i+1)::text as foo2,
    'bar' || '_' || _text_param || '_' || (i+1)::text as bar2,
    (_ts_param::date) + ((i+1)::text || ' days')::interval as datetime2,
    'long_foo_bar_' || '_' || _text_param || '_' || (i+2)::text as long_foo_bar, 
    (i % 2)::boolean and _bool_param as is_foobar
from
    generate_series(1, _records) as i
$$;
create function public.test_func_v1(
    _records int,
    _text_param text,
    _int_param int,
    _ts_param timestamp,
    _bool_param bool
) 
returns table(
    id1 int, 
    foo1 text, 
    bar1 text, 
    datetime1 timestamp, 
    id2 int, 
    foo2 text, 
    bar2 text, 
    datetime2 timestamp,
    long_foo_bar text, 
    is_foobar bool
)
stable
language sql
as
$$
select
    i + _int_param as id1,
    'foo' || '_' || _text_param || '_' || i::text as foo1,
    'bar' || i::text as bar1,
    (_ts_param::date) + (i::text || ' days')::interval as datetime1,
    i+1 + _int_param as id2,
    'foo' || '_' || _text_param || '_' || (i+1)::text as foo2,
    'bar' || '_' || _text_param || '_' || (i+1)::text as bar2,
    (_ts_param::date) + ((i+1)::text || ' days')::interval as datetime2,
    'long_foo_bar_' || '_' || _text_param || '_' || (i+2)::text as long_foo_bar, 
    (i % 2)::boolean and _bool_param as is_foobar
from
    generate_series(1, _records) as i
$$;

Interactive Chart

Conclusions

  1. Do not parse test results while drinking!

  2. .NET9 is really not that optimized compared.NET8, as I was led previously to believe.

  3. When we ask which backend web framework is the fastest, we should first ask how many concurrent users there are and what the average response size is. Not all web frameworks behave the same in different environments.

  4. RUST and GO are not suitable for this type of application. They may shine in system programming and low-level work, but when it comes to returning responses from a web server, it's anything but these two.

  5. Having said that, these performances depend largely on a web server's performances, not on your language implementation.

  6. I'm not as good at optimization as I thought I was; there is so much to learn yet.

  7. If you want the best possible web performance, choose good old PHP on the Swoole server.

  8. If you want a low-code platform for rapid development, use PostgREST, Omnigres, or NpgsqlRest.

To receive notifications about new posts and updates, consider subscribing to my LinkdIn page:
vb-software linkedin

You will receive notifications about new posts on your LinkedIn feed.
Comments