f7d23913创建于 2023年2月27日历史提交
\! @abs_bindir@/gs_guc reload -D @abs_srcdir@/tmp_check/datanode1/ -c "instr_unique_sql_count=10000"
\c postgres

create schema slow_sql;
SET search_path = slow_sql, public;
create table slow_sql.test(col1 int, col2 numeric, col3 text);
create index index1 on slow_sql.test(col1);
create index index2 on slow_sql.test(col2);
create index index3 on slow_sql.test(col3);
insert into slow_sql.test values (generate_series(1,100), generate_series(101,200), generate_series(201,300));
delete from statement_history;
set track_stmt_stat_level='L0,L0';
-- test col1(integer)
select col1 from slow_sql.test where col1 = 12;
select col2 from slow_sql.test where col1 = 123456781234567812345678;
select col3 from slow_sql.test where col1 = '12';
select * from slow_sql.test where col1::numeric = 12;
select * from slow_sql.test where col1::text = '12';
-- test col2(numeric)
select col1 from slow_sql.test where col2 = 123456781234567812345678;
select col2 from slow_sql.test where col2 = 12;
select col3 from slow_sql.test where col2 = '123456781234567812345678';
select * from slow_sql.test where col2::integer = 123456781234567812345678;
select * from slow_sql.test where col2::text = '123456781234567812345678';
-- test col3(text)
select col1 from slow_sql.test where col3 = '12';
select col2 from slow_sql.test where col3 = 12;
select col3 from slow_sql.test where col3 = 123456781234567812345678;
select * from slow_sql.test where col3::integer = 12;
select * from slow_sql.test where col3::numeric = 12;
-- test limit
select col1 from slow_sql.test where col1 = 12 limit 4999;
select col2 from slow_sql.test where col1 = 12 limit 5000;
select col3 from slow_sql.test where col1 = 12 limit 5001;
-- test all
select col1,col2 from slow_sql.test where col1 = 12 limit 4999;
select col1,col3 from slow_sql.test where col1 = 123456781234567812345678 limit 4999;
select col2,col3 from slow_sql.test where col1 = 12 limit 5000;
select col1,col2,col3 from slow_sql.test where col1 = 123456781234567812345678 limit 5000;
set track_stmt_stat_level='OFF,L0';
--wait insert history
insert into slow_sql.test values (generate_series(1,10000), generate_series(10001,20000), generate_series(20001,30000));
select schema_name, query, advise from statement_history order by start_time;
\! @abs_bindir@/gs_guc reload -D @abs_srcdir@/tmp_check/datanode1/ -c "instr_unique_sql_count=100"