6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-23 14:03:06 +01:00
firebird-qa/tests/bugs/core_5421_test.py

79 lines
1.8 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-25 22:55:48 +01:00
"""
ID: issue-5694
ISSUE: 5694
TITLE: Performance degradation in FB 3.0.2 compared to FB 2.5.7
DESCRIPTION:
JIRA: CORE-5421
FBTEST: bugs.core_5421
2022-01-25 22:55:48 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
recreate table tmain(id int, ekey int);
2022-01-25 22:55:48 +01:00
recreate table tdetl(doc_id int, dts timestamp);
2021-04-26 20:07:00 +02:00
set term ^;
execute block as
declare n int = 10000; -- 7600000;
declare d int = 100; -- 5000;
declare i int = 0;
begin
while ( i < n ) do
begin
insert into tdetl(doc_id, dts) values( :i, current_date-rand()*:d )
returning :i+1 into i;
end
insert into tmain(id, ekey) values(0, 100);
end^
set term ;^
commit;
create index c5421_tmain_id on tmain(id);
create index c5421_tmain_ekey on tmain(ekey);
create index c5421_tdetl_doc_id on tdetl(doc_id);
create descending index c5421_tdetl_dts on tdetl(dts);
commit;
--set width rel_name 8;
--set width idx_name 30;
--select ri.rdb$relation_name rel_name, ri.rdb$index_name idx_name, ri.rdb$statistics
--from rdb$indices ri where ri.rdb$index_name starting with 'C5421';
set list on;
set plan on;
--set stat on;
set count on;
2022-01-25 22:55:48 +01:00
select first 1 d.doc_id --, d.dts
from tmain c
2021-04-26 20:07:00 +02:00
join tdetl d ON d.doc_id = c.id
where
c.ekey = 100 and
d.dts <= 'tomorrow'
order by
d.dts desc
;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
act = isql_act('db', test_script)
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
PLAN SORT (JOIN (C INDEX (C5421_TMAIN_EKEY), D INDEX (C5421_TDETL_DOC_ID)))
DOC_ID 0
Records affected: 1
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
@pytest.mark.version('>=3')
def test_1(act: Action):
act.expected_stdout = expected_stdout
act.execute()
assert act.clean_stdout == act.clean_expected_stdout
2021-04-26 20:07:00 +02:00