Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbbe7315

Browse files
a.pervushinaAlena Rybakina
a.pervushina
authored and
Alena Rybakina
committed
[PGPRO-6755] Refactor machine dependent tests
Tags: aqo
1 parentcd346ff commitbbe7315

File tree

4 files changed

+56
-16
lines changed

4 files changed

+56
-16
lines changed

‎expected/forced_stat_collection.out‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,21 @@ SELECT * FROM aqo_data;
3838
----+-----+-----------+----------+---------+-------------+------
3939
(0 rows)
4040

41-
SELECT learn_aqo,use_aqo,auto_tuning,cardinality_error_without_aqo ce,executions_without_aqo nex
41+
CREATE OR REPLACE FUNCTION round_array (double precision[])
42+
RETURNS double precision[]
43+
LANGUAGE SQL
44+
AS $$
45+
SELECT array_agg(round(elem::numeric, 3))
46+
FROM unnest($1) as arr(elem);
47+
$$;
48+
SELECT learn_aqo,use_aqo,auto_tuning,round_array(cardinality_error_without_aqo) ce,executions_without_aqo nex
4249
FROM aqo_queries AS aq JOIN aqo_query_stat AS aqs
4350
ON aq.queryid = aqs.queryid
4451
ORDER BY (cardinality_error_without_aqo);
45-
learn_aqo | use_aqo | auto_tuning | ce | nex
46-
-----------+---------+-------------+----------------------+-----
47-
f | f | f | {0.8637762840285226} | 1
48-
f | f | f | {2.9634630129852053} | 1
52+
learn_aqo | use_aqo | auto_tuning |ce | nex
53+
-----------+---------+-------------+---------+-----
54+
f | f | f | {0.864} | 1
55+
f | f | f | {2.963} | 1
4956
(2 rows)
5057

5158
SELECT query_text FROM aqo_query_texts ORDER BY (md5(query_text));

‎expected/unsupported.out‎

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,17 @@ SELECT * FROM
485485
-- any prediction on number of fetched tuples.
486486
-- So, if selectivity was wrong we could make bad choice of Scan operation.
487487
-- For example, we could choose suboptimal index.
488+
--
489+
-- Returns string-by-string explain of a query. Made for removing some strings
490+
-- from the explain output.
491+
--
492+
CREATE OR REPLACE FUNCTION expln(query_string text) RETURNS SETOF text AS $$
493+
BEGIN
494+
RETURN QUERY
495+
EXECUTE format('EXPLAIN (ANALYZE, VERBOSE, COSTS OFF, TIMING OFF, SUMMARY OFF) %s', query_string);
496+
RETURN;
497+
END;
498+
$$ LANGUAGE PLPGSQL;
488499
-- Turn off statistics gathering for simple demonstration of filtering problem.
489500
ALTER TABLE t SET (autovacuum_enabled = 'false');
490501
CREATE INDEX ind1 ON t(x);
@@ -520,21 +531,22 @@ SELECT count(*) FROM t WHERE x < 3 AND mod(x,3) = 1;
520531
50
521532
(1 row)
522533

523-
EXPLAIN (ANALYZE, COSTS OFF, TIMING OFF, SUMMARY OFF)
524-
SELECT count(*) FROM t WHERE x < 3 AND mod(x,3) = 1;
525-
QUERY PLAN
534+
SELECT str AS result
535+
FROM expln('SELECT count(*) FROM t WHERE x < 3 AND mod(x,3) = 1') AS str
536+
WHERE str NOT LIKE '%Heap Blocks%';
537+
result
526538
-----------------------------------------------------------------
527539
Aggregate (actual rows=1 loops=1)
528540
AQO not used
529-
-> Bitmap Heap Scan on t (actual rows=50 loops=1)
541+
Output: count(*)
542+
-> Bitmap Heap Scan on public.t (actual rows=50 loops=1)
530543
AQO: rows=50, error=0%
531-
Recheck Cond: (mod(x, 3) = 1)
532-
Filter: (x < 3)
544+
Recheck Cond: (mod(t.x, 3) = 1)
545+
Filter: (t.x < 3)
533546
Rows Removed by Filter: 300
534-
Heap Blocks: exact=5
535547
-> Bitmap Index Scan on ind2 (actual rows=350 loops=1)
536548
AQO not used
537-
Index Cond: (mod(x, 3) = 1)
549+
Index Cond: (mod(t.x, 3) = 1)
538550
Using aqo: true
539551
AQO mode: LEARN
540552
JOINS: 0

‎sql/forced_stat_collection.sql‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,15 @@ SELECT count(*) FROM person WHERE age<18;
3030
SELECTcount(*)FROM personWHERE age<18AND passportIS NOT NULL;
3131
SELECT*FROM aqo_data;
3232

33-
SELECT learn_aqo,use_aqo,auto_tuning,cardinality_error_without_aqo ce,executions_without_aqo nex
33+
CREATE OR REPLACEFUNCTIONround_array (double precision[])
34+
RETURNSdouble precision[]
35+
LANGUAGE SQL
36+
AS $$
37+
SELECT array_agg(round(elem::numeric,3))
38+
FROM unnest($1)as arr(elem);
39+
$$;
40+
41+
SELECT learn_aqo,use_aqo,auto_tuning,round_array(cardinality_error_without_aqo) ce,executions_without_aqo nex
3442
FROM aqo_queriesAS aqJOIN aqo_query_statAS aqs
3543
ONaq.queryid=aqs.queryid
3644
ORDER BY (cardinality_error_without_aqo);

‎sql/unsupported.sql‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ SELECT * FROM
139139
-- So, if selectivity was wrong we could make bad choice of Scan operation.
140140
-- For example, we could choose suboptimal index.
141141

142+
--
143+
-- Returns string-by-string explain of a query. Made for removing some strings
144+
-- from the explain output.
145+
--
146+
CREATE OR REPLACEFUNCTIONexpln(query_stringtext) RETURNS SETOFtextAS $$
147+
BEGIN
148+
RETURN QUERY
149+
EXECUTE format('EXPLAIN (ANALYZE, VERBOSE, COSTS OFF, TIMING OFF, SUMMARY OFF) %s', query_string);
150+
RETURN;
151+
END;
152+
$$ LANGUAGE PLPGSQL;
153+
142154
-- Turn off statistics gathering for simple demonstration of filtering problem.
143155
ALTERTABLE tSET (autovacuum_enabled='false');
144156
CREATEINDEXind1ON t(x);
@@ -151,8 +163,9 @@ EXPLAIN (ANALYZE, COSTS OFF, TIMING OFF, SUMMARY OFF)
151163
-- Here we filter more tuples than with the ind1 index.
152164
CREATEINDEXind2ON t(mod(x,3));
153165
SELECTcount(*)FROM tWHERE x<3AND mod(x,3)=1;
154-
EXPLAIN (ANALYZE, COSTS OFF, TIMING OFF, SUMMARY OFF)
155-
SELECTcount(*)FROM tWHERE x<3AND mod(x,3)=1;
166+
SELECT strAS result
167+
FROM expln('SELECT count(*) FROM t WHERE x < 3 AND mod(x,3) = 1')AS str
168+
WHERE str NOTLIKE'%Heap Blocks%';
156169

157170
-- Best choice is ...
158171
ANALYZE t;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp