--setup================== drop COLLATION if exists ignore_accent_case; CREATE COLLATION ignore_accent_case (provider = icu, deterministic = false, locale = 'und-u-ks-level1'); drop COLLATION if exists case_insensitive; CREATE COLLATION case_insensitive (provider = icu, locale = 'und-u-ks-level2', deterministic = false); create table t_plan(id int, name text, address text); ALTER TABLE t_plan ALTER COLUMN name SET STATISTICS 10000; insert into t_plan select g, g::text,g::text FROM generate_series(1, 10000) g; insert into t_plan select * from t_plan; analyze t_plan; SELECT tablename, attname, correlation, inherited, n_distinct, array_length(most_common_vals, 1) as length_most_common_vals ,array_length(most_common_freqs, 1) as length_most_common_freqs FROM pg_stats WHERE tablename = 't_plan'; tablename | attname | correlation | inherited | n_distinct | length_most_common_vals | length_most_common_freqs -----------+---------+-------------+-----------+------------+-------------------------+-------------------------- t_plan | name | 0.409402 | f | -0.5 | 10000 | 10000 t_plan | id | 0.500075 | f | -0.5 | 100 | 100 t_plan | address | 0.409402 | f | -0.5 | 100 | 100 (3 rows) --test sql model test_explain.sql: explain analyze select count(*) from t_plan where name = 'MY_NAEM' COLLATE ignore_accent_case; explain analyze select count(*) from t_plan where name = 'MY_NAEM' COLLATE ignore_accent_case; explain analyze select count(*) from t_plan where name = 'MY_NAEM' COLLATE ignore_accent_case; explain analyze select count(*) from t_plan where name = 'MY_NAEM' COLLATE ignore_accent_case; explain analyze select count(*) from t_plan where name = 'MY_NAEM' COLLATE ignore_accent_case; explain analyze select count(*) from t_plan where name = 'MY_NAEM' COLLATE ignore_accent_case; explain analyze select count(*) from t_plan where name = 'MY_NAEM' COLLATE ignore_accent_case; explain analyze select count(*) from t_plan where name = 'MY_NAEM' COLLATE ignore_accent_case; explain analyze select count(*) from t_plan where name = 'MY_NAEM' COLLATE ignore_accent_case; explain analyze select count(*) from t_plan where name = 'MY_NAEM' COLLATE ignore_accent_case; cur_version=v4 for af in 1 5000 9999; do ./start_pg.sh; >/dev/null echo $af; cat test/test_explain.sql|sed "s/MY_NAEM/$af/g"|psql xman7 >test/$cur_version.test_explain.$af.sql.out; grep "Planning Time" test/$cur_version.test_explain.$af.sql.out|awk '{print $3}'; ./stop_pg.sh;>/dev/null echo ""; echo ""; done cur_version=v0 for af in 1 5000 9999; do ./start_pg.sh; >/dev/null echo $af; cat test/test_explain.sql|sed "s/MY_NAEM/$af/g"|psql xman7 >test/$cur_version.test_explain.$af.sql.out; grep "Planning Time" test/$cur_version.test_explain.$af.sql.out|awk '{print $3}'; ./stop_pg.sh;>/dev/null echo ""; echo ""; done