qameta / allure-testops-deployment

Helm Charts for Allure TestOps Deployment
8 stars 22 forks source link

Slow insert into "test_result" #103

Closed polarnik closed 1 month ago

polarnik commented 1 month ago

Allure Report 4.26.5 is using non optimal SQL Request

insert into "test_result" (
    "launch_id", "test_session_id", 
    "job_run_id", "id", "test_case_id", 
    "name", "history_key", "hidden", 
    "external", "created_by", "created_date", 
    "last_modified_by", "last_modified_date"
) 
values (
    $1, $2, cast($3 as bigint), default, cast($4 as bigint), 
    $5, $6, $7, $8, $9, $10, $11, $12
) 
on conflict ("id") do update set 
    "launch_id" = "excluded"."launch_id", 
    "test_session_id" = "excluded"."test_session_id", 
    "job_run_id" = "excluded"."job_run_id", 
    "test_case_id" = "excluded"."test_case_id", 
    "name" = "excluded"."name", 
    "history_key" = "excluded"."history_key", 
    "hidden" = $13, 
    "external" = $14, 
    "last_modified_by" = $15, 
    "last_modified_date" = $16 
returning 
    "test_result"."id", 
    "test_result"."test_case_id"

It uses default for the id, it means new records will have new id values, but it has a check on conflict ("id") do update set ...

image

The optimal query is

insert into "test_result" (
    "launch_id", "test_session_id", 
    "job_run_id", "id", "test_case_id", 
    "name", "history_key", "hidden", 
    "external", "created_by", "created_date", 
    "last_modified_by", "last_modified_date"
) 
values (
    $1, $2, cast($3 as bigint), default, cast($4 as bigint), 
    $5, $6, $7, $8, $9, $10, $11, $12
) 
returning 
    "test_result"."id", 
    "test_result"."test_case_id"

There is a one of the TOP requests

polarnik commented 1 month ago

I will move it into the support requests