mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-02-11 19:20:40 +08:00
Still another try at stabilizing stats_ext test results.
The stats_ext test is not expecting that autovacuum will touch any of its tables; an expectation falsified by commitb07642dbc
. Although I'm suspicious that there's something else going on that makes extended stats estimates not 100% reproducible, it's pretty easy to demonstrate that there are places in this test that fail if an autovacuum updates the table's stats unexpectedly. Hence, revert the band-aid changes made by2dc16efed
and24566b359
in favor of summarily disabling autovacuum for all the tables that this test checks estimated rowcounts for. Also remove an evidently obsolete comment at the head of the test. Discussion: https://postgr.es/m/15012.1585623298@sss.pgh.pa.us
This commit is contained in:
parent
69360b3458
commit
0936d1b6ff
@ -1,7 +1,9 @@
|
|||||||
-- Generic extended statistics support
|
-- Generic extended statistics support
|
||||||
-- We will be checking execution plans without/with statistics, so
|
--
|
||||||
-- let's make sure we get simple non-parallel plans. Also set the
|
-- Note: tables for which we check estimated row counts should be created
|
||||||
-- work_mem low so that we can use small amounts of data.
|
-- with autovacuum_enabled = off, so that we don't have unstable results
|
||||||
|
-- from auto-analyze happening when we didn't expect it.
|
||||||
|
--
|
||||||
-- check the number of estimated/actual rows in the top node
|
-- check the number of estimated/actual rows in the top node
|
||||||
create function check_estimated_rows(text) returns table (estimated int, actual int)
|
create function check_estimated_rows(text) returns table (estimated int, actual int)
|
||||||
language plpgsql as
|
language plpgsql as
|
||||||
@ -184,7 +186,8 @@ CREATE TABLE ndistinct (
|
|||||||
filler3 DATE,
|
filler3 DATE,
|
||||||
c INT,
|
c INT,
|
||||||
d INT
|
d INT
|
||||||
);
|
)
|
||||||
|
WITH (autovacuum_enabled = off);
|
||||||
-- over-estimates when using only per-column statistics
|
-- over-estimates when using only per-column statistics
|
||||||
INSERT INTO ndistinct (a, b, c, filler1)
|
INSERT INTO ndistinct (a, b, c, filler1)
|
||||||
SELECT i/100, i/100, i/100, cash_words((i/100)::money)
|
SELECT i/100, i/100, i/100, cash_words((i/100)::money)
|
||||||
@ -279,7 +282,7 @@ INSERT INTO ndistinct (a, b, c, filler1)
|
|||||||
SELECT mod(i,50), mod(i,51), mod(i,32),
|
SELECT mod(i,50), mod(i,51), mod(i,32),
|
||||||
cash_words(mod(i,33)::int::money)
|
cash_words(mod(i,33)::int::money)
|
||||||
FROM generate_series(1,5000) s(i);
|
FROM generate_series(1,5000) s(i);
|
||||||
VACUUM (ANALYZE) ndistinct;
|
ANALYZE ndistinct;
|
||||||
SELECT s.stxkind, d.stxdndistinct
|
SELECT s.stxkind, d.stxdndistinct
|
||||||
FROM pg_statistic_ext s, pg_statistic_ext_data d
|
FROM pg_statistic_ext s, pg_statistic_ext_data d
|
||||||
WHERE s.stxrelid = 'ndistinct'::regclass
|
WHERE s.stxrelid = 'ndistinct'::regclass
|
||||||
@ -369,13 +372,14 @@ CREATE TABLE functional_dependencies (
|
|||||||
filler3 DATE,
|
filler3 DATE,
|
||||||
c INT,
|
c INT,
|
||||||
d TEXT
|
d TEXT
|
||||||
);
|
)
|
||||||
|
WITH (autovacuum_enabled = off);
|
||||||
CREATE INDEX fdeps_ab_idx ON functional_dependencies (a, b);
|
CREATE INDEX fdeps_ab_idx ON functional_dependencies (a, b);
|
||||||
CREATE INDEX fdeps_abc_idx ON functional_dependencies (a, b, c);
|
CREATE INDEX fdeps_abc_idx ON functional_dependencies (a, b, c);
|
||||||
-- random data (no functional dependencies)
|
-- random data (no functional dependencies)
|
||||||
INSERT INTO functional_dependencies (a, b, c, filler1)
|
INSERT INTO functional_dependencies (a, b, c, filler1)
|
||||||
SELECT mod(i, 23), mod(i, 29), mod(i, 31), i FROM generate_series(1,5000) s(i);
|
SELECT mod(i, 23), mod(i, 29), mod(i, 31), i FROM generate_series(1,5000) s(i);
|
||||||
VACUUM (ANALYZE) functional_dependencies;
|
ANALYZE functional_dependencies;
|
||||||
SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1''');
|
SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1''');
|
||||||
estimated | actual
|
estimated | actual
|
||||||
-----------+--------
|
-----------+--------
|
||||||
@ -408,7 +412,7 @@ TRUNCATE functional_dependencies;
|
|||||||
DROP STATISTICS func_deps_stat;
|
DROP STATISTICS func_deps_stat;
|
||||||
INSERT INTO functional_dependencies (a, b, c, filler1)
|
INSERT INTO functional_dependencies (a, b, c, filler1)
|
||||||
SELECT mod(i,100), mod(i,50), mod(i,25), i FROM generate_series(1,5000) s(i);
|
SELECT mod(i,100), mod(i,50), mod(i,25), i FROM generate_series(1,5000) s(i);
|
||||||
VACUUM (ANALYZE) functional_dependencies;
|
ANALYZE functional_dependencies;
|
||||||
SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1''');
|
SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1''');
|
||||||
estimated | actual
|
estimated | actual
|
||||||
-----------+--------
|
-----------+--------
|
||||||
@ -741,7 +745,7 @@ SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE
|
|||||||
25 | 50
|
25 | 50
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
VACUUM (ANALYZE) functional_dependencies;
|
ANALYZE functional_dependencies;
|
||||||
SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1'' AND c = 1');
|
SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1'' AND c = 1');
|
||||||
estimated | actual
|
estimated | actual
|
||||||
-----------+--------
|
-----------+--------
|
||||||
@ -754,7 +758,8 @@ CREATE TABLE functional_dependencies_multi (
|
|||||||
b INTEGER,
|
b INTEGER,
|
||||||
c INTEGER,
|
c INTEGER,
|
||||||
d INTEGER
|
d INTEGER
|
||||||
);
|
)
|
||||||
|
WITH (autovacuum_enabled = off);
|
||||||
INSERT INTO functional_dependencies_multi (a, b, c, d)
|
INSERT INTO functional_dependencies_multi (a, b, c, d)
|
||||||
SELECT
|
SELECT
|
||||||
mod(i,7),
|
mod(i,7),
|
||||||
@ -838,11 +843,12 @@ CREATE TABLE mcv_lists (
|
|||||||
filler3 DATE,
|
filler3 DATE,
|
||||||
c INT,
|
c INT,
|
||||||
d TEXT
|
d TEXT
|
||||||
);
|
)
|
||||||
|
WITH (autovacuum_enabled = off);
|
||||||
-- random data (no MCV list)
|
-- random data (no MCV list)
|
||||||
INSERT INTO mcv_lists (a, b, c, filler1)
|
INSERT INTO mcv_lists (a, b, c, filler1)
|
||||||
SELECT mod(i,37), mod(i,41), mod(i,43), mod(i,47) FROM generate_series(1,5000) s(i);
|
SELECT mod(i,37), mod(i,41), mod(i,43), mod(i,47) FROM generate_series(1,5000) s(i);
|
||||||
VACUUM (ANALYZE) mcv_lists;
|
ANALYZE mcv_lists;
|
||||||
SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''');
|
SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''');
|
||||||
estimated | actual
|
estimated | actual
|
||||||
-----------+--------
|
-----------+--------
|
||||||
@ -875,7 +881,7 @@ TRUNCATE mcv_lists;
|
|||||||
DROP STATISTICS mcv_lists_stats;
|
DROP STATISTICS mcv_lists_stats;
|
||||||
INSERT INTO mcv_lists (a, b, c, filler1)
|
INSERT INTO mcv_lists (a, b, c, filler1)
|
||||||
SELECT mod(i,100), mod(i,50), mod(i,25), i FROM generate_series(1,5000) s(i);
|
SELECT mod(i,100), mod(i,50), mod(i,25), i FROM generate_series(1,5000) s(i);
|
||||||
VACUUM (ANALYZE) mcv_lists;
|
ANALYZE mcv_lists;
|
||||||
SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''');
|
SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''');
|
||||||
estimated | actual
|
estimated | actual
|
||||||
-----------+--------
|
-----------+--------
|
||||||
@ -1175,7 +1181,7 @@ SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b =
|
|||||||
1 | 50
|
1 | 50
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
VACUUM (ANALYZE) mcv_lists;
|
ANALYZE mcv_lists;
|
||||||
SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''');
|
SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''');
|
||||||
estimated | actual
|
estimated | actual
|
||||||
-----------+--------
|
-----------+--------
|
||||||
@ -1192,7 +1198,7 @@ INSERT INTO mcv_lists (a, b, c, filler1)
|
|||||||
(CASE WHEN mod(i,25) = 1 THEN NULL ELSE mod(i,25) END),
|
(CASE WHEN mod(i,25) = 1 THEN NULL ELSE mod(i,25) END),
|
||||||
i
|
i
|
||||||
FROM generate_series(1,5000) s(i);
|
FROM generate_series(1,5000) s(i);
|
||||||
VACUUM (ANALYZE) mcv_lists;
|
ANALYZE mcv_lists;
|
||||||
SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND b IS NULL');
|
SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND b IS NULL');
|
||||||
estimated | actual
|
estimated | actual
|
||||||
-----------+--------
|
-----------+--------
|
||||||
@ -1259,7 +1265,7 @@ SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IN (0, 1) AN
|
|||||||
-- test pg_mcv_list_items with a very simple (single item) MCV list
|
-- test pg_mcv_list_items with a very simple (single item) MCV list
|
||||||
TRUNCATE mcv_lists;
|
TRUNCATE mcv_lists;
|
||||||
INSERT INTO mcv_lists (a, b, c) SELECT 1, 2, 3 FROM generate_series(1,1000) s(i);
|
INSERT INTO mcv_lists (a, b, c) SELECT 1, 2, 3 FROM generate_series(1,1000) s(i);
|
||||||
VACUUM (ANALYZE) mcv_lists;
|
ANALYZE mcv_lists;
|
||||||
SELECT m.*
|
SELECT m.*
|
||||||
FROM pg_statistic_ext s, pg_statistic_ext_data d,
|
FROM pg_statistic_ext s, pg_statistic_ext_data d,
|
||||||
pg_mcv_list_items(d.stxdmcv) m
|
pg_mcv_list_items(d.stxdmcv) m
|
||||||
@ -1280,7 +1286,7 @@ INSERT INTO mcv_lists (a, b, c, d)
|
|||||||
(CASE WHEN mod(i,2) = 0 THEN NULL ELSE 0 END),
|
(CASE WHEN mod(i,2) = 0 THEN NULL ELSE 0 END),
|
||||||
(CASE WHEN mod(i,2) = 0 THEN NULL ELSE 'x' END)
|
(CASE WHEN mod(i,2) = 0 THEN NULL ELSE 'x' END)
|
||||||
FROM generate_series(1,5000) s(i);
|
FROM generate_series(1,5000) s(i);
|
||||||
VACUUM (ANALYZE) mcv_lists;
|
ANALYZE mcv_lists;
|
||||||
SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE b = ''x'' OR d = ''x''');
|
SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE b = ''x'' OR d = ''x''');
|
||||||
estimated | actual
|
estimated | actual
|
||||||
-----------+--------
|
-----------+--------
|
||||||
@ -1337,7 +1343,8 @@ CREATE TABLE mcv_lists_uuid (
|
|||||||
a UUID,
|
a UUID,
|
||||||
b UUID,
|
b UUID,
|
||||||
c UUID
|
c UUID
|
||||||
);
|
)
|
||||||
|
WITH (autovacuum_enabled = off);
|
||||||
INSERT INTO mcv_lists_uuid (a, b, c)
|
INSERT INTO mcv_lists_uuid (a, b, c)
|
||||||
SELECT
|
SELECT
|
||||||
md5(mod(i,100)::text)::uuid,
|
md5(mod(i,100)::text)::uuid,
|
||||||
@ -1378,7 +1385,8 @@ CREATE TABLE mcv_lists_arrays (
|
|||||||
a TEXT[],
|
a TEXT[],
|
||||||
b NUMERIC[],
|
b NUMERIC[],
|
||||||
c INT[]
|
c INT[]
|
||||||
);
|
)
|
||||||
|
WITH (autovacuum_enabled = off);
|
||||||
INSERT INTO mcv_lists_arrays (a, b, c)
|
INSERT INTO mcv_lists_arrays (a, b, c)
|
||||||
SELECT
|
SELECT
|
||||||
ARRAY[md5((i/100)::text), md5((i/100-1)::text), md5((i/100+1)::text)],
|
ARRAY[md5((i/100)::text), md5((i/100-1)::text), md5((i/100+1)::text)],
|
||||||
@ -1393,12 +1401,13 @@ CREATE TABLE mcv_lists_bool (
|
|||||||
a BOOL,
|
a BOOL,
|
||||||
b BOOL,
|
b BOOL,
|
||||||
c BOOL
|
c BOOL
|
||||||
);
|
)
|
||||||
|
WITH (autovacuum_enabled = off);
|
||||||
INSERT INTO mcv_lists_bool (a, b, c)
|
INSERT INTO mcv_lists_bool (a, b, c)
|
||||||
SELECT
|
SELECT
|
||||||
(mod(i,2) = 0), (mod(i,4) = 0), (mod(i,8) = 0)
|
(mod(i,2) = 0), (mod(i,4) = 0), (mod(i,8) = 0)
|
||||||
FROM generate_series(1,10000) s(i);
|
FROM generate_series(1,10000) s(i);
|
||||||
VACUUM (ANALYZE) mcv_lists_bool;
|
ANALYZE mcv_lists_bool;
|
||||||
SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE a AND b AND c');
|
SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE a AND b AND c');
|
||||||
estimated | actual
|
estimated | actual
|
||||||
-----------+--------
|
-----------+--------
|
||||||
@ -1456,7 +1465,8 @@ CREATE TABLE mcv_lists_multi (
|
|||||||
b INTEGER,
|
b INTEGER,
|
||||||
c INTEGER,
|
c INTEGER,
|
||||||
d INTEGER
|
d INTEGER
|
||||||
);
|
)
|
||||||
|
WITH (autovacuum_enabled = off);
|
||||||
INSERT INTO mcv_lists_multi (a, b, c, d)
|
INSERT INTO mcv_lists_multi (a, b, c, d)
|
||||||
SELECT
|
SELECT
|
||||||
mod(i,5),
|
mod(i,5),
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
-- Generic extended statistics support
|
-- Generic extended statistics support
|
||||||
|
|
||||||
-- We will be checking execution plans without/with statistics, so
|
--
|
||||||
-- let's make sure we get simple non-parallel plans. Also set the
|
-- Note: tables for which we check estimated row counts should be created
|
||||||
-- work_mem low so that we can use small amounts of data.
|
-- with autovacuum_enabled = off, so that we don't have unstable results
|
||||||
|
-- from auto-analyze happening when we didn't expect it.
|
||||||
|
--
|
||||||
|
|
||||||
-- check the number of estimated/actual rows in the top node
|
-- check the number of estimated/actual rows in the top node
|
||||||
create function check_estimated_rows(text) returns table (estimated int, actual int)
|
create function check_estimated_rows(text) returns table (estimated int, actual int)
|
||||||
@ -137,7 +139,8 @@ CREATE TABLE ndistinct (
|
|||||||
filler3 DATE,
|
filler3 DATE,
|
||||||
c INT,
|
c INT,
|
||||||
d INT
|
d INT
|
||||||
);
|
)
|
||||||
|
WITH (autovacuum_enabled = off);
|
||||||
|
|
||||||
-- over-estimates when using only per-column statistics
|
-- over-estimates when using only per-column statistics
|
||||||
INSERT INTO ndistinct (a, b, c, filler1)
|
INSERT INTO ndistinct (a, b, c, filler1)
|
||||||
@ -191,7 +194,7 @@ INSERT INTO ndistinct (a, b, c, filler1)
|
|||||||
cash_words(mod(i,33)::int::money)
|
cash_words(mod(i,33)::int::money)
|
||||||
FROM generate_series(1,5000) s(i);
|
FROM generate_series(1,5000) s(i);
|
||||||
|
|
||||||
VACUUM (ANALYZE) ndistinct;
|
ANALYZE ndistinct;
|
||||||
|
|
||||||
SELECT s.stxkind, d.stxdndistinct
|
SELECT s.stxkind, d.stxdndistinct
|
||||||
FROM pg_statistic_ext s, pg_statistic_ext_data d
|
FROM pg_statistic_ext s, pg_statistic_ext_data d
|
||||||
@ -236,7 +239,8 @@ CREATE TABLE functional_dependencies (
|
|||||||
filler3 DATE,
|
filler3 DATE,
|
||||||
c INT,
|
c INT,
|
||||||
d TEXT
|
d TEXT
|
||||||
);
|
)
|
||||||
|
WITH (autovacuum_enabled = off);
|
||||||
|
|
||||||
CREATE INDEX fdeps_ab_idx ON functional_dependencies (a, b);
|
CREATE INDEX fdeps_ab_idx ON functional_dependencies (a, b);
|
||||||
CREATE INDEX fdeps_abc_idx ON functional_dependencies (a, b, c);
|
CREATE INDEX fdeps_abc_idx ON functional_dependencies (a, b, c);
|
||||||
@ -245,7 +249,7 @@ CREATE INDEX fdeps_abc_idx ON functional_dependencies (a, b, c);
|
|||||||
INSERT INTO functional_dependencies (a, b, c, filler1)
|
INSERT INTO functional_dependencies (a, b, c, filler1)
|
||||||
SELECT mod(i, 23), mod(i, 29), mod(i, 31), i FROM generate_series(1,5000) s(i);
|
SELECT mod(i, 23), mod(i, 29), mod(i, 31), i FROM generate_series(1,5000) s(i);
|
||||||
|
|
||||||
VACUUM (ANALYZE) functional_dependencies;
|
ANALYZE functional_dependencies;
|
||||||
|
|
||||||
SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1''');
|
SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1''');
|
||||||
|
|
||||||
@ -267,7 +271,7 @@ DROP STATISTICS func_deps_stat;
|
|||||||
INSERT INTO functional_dependencies (a, b, c, filler1)
|
INSERT INTO functional_dependencies (a, b, c, filler1)
|
||||||
SELECT mod(i,100), mod(i,50), mod(i,25), i FROM generate_series(1,5000) s(i);
|
SELECT mod(i,100), mod(i,50), mod(i,25), i FROM generate_series(1,5000) s(i);
|
||||||
|
|
||||||
VACUUM (ANALYZE) functional_dependencies;
|
ANALYZE functional_dependencies;
|
||||||
|
|
||||||
SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1''');
|
SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1''');
|
||||||
|
|
||||||
@ -396,7 +400,7 @@ ALTER TABLE functional_dependencies ALTER COLUMN c TYPE numeric;
|
|||||||
|
|
||||||
SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1'' AND c = 1');
|
SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1'' AND c = 1');
|
||||||
|
|
||||||
VACUUM (ANALYZE) functional_dependencies;
|
ANALYZE functional_dependencies;
|
||||||
|
|
||||||
SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1'' AND c = 1');
|
SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1'' AND c = 1');
|
||||||
|
|
||||||
@ -406,7 +410,8 @@ CREATE TABLE functional_dependencies_multi (
|
|||||||
b INTEGER,
|
b INTEGER,
|
||||||
c INTEGER,
|
c INTEGER,
|
||||||
d INTEGER
|
d INTEGER
|
||||||
);
|
)
|
||||||
|
WITH (autovacuum_enabled = off);
|
||||||
|
|
||||||
INSERT INTO functional_dependencies_multi (a, b, c, d)
|
INSERT INTO functional_dependencies_multi (a, b, c, d)
|
||||||
SELECT
|
SELECT
|
||||||
@ -448,13 +453,14 @@ CREATE TABLE mcv_lists (
|
|||||||
filler3 DATE,
|
filler3 DATE,
|
||||||
c INT,
|
c INT,
|
||||||
d TEXT
|
d TEXT
|
||||||
);
|
)
|
||||||
|
WITH (autovacuum_enabled = off);
|
||||||
|
|
||||||
-- random data (no MCV list)
|
-- random data (no MCV list)
|
||||||
INSERT INTO mcv_lists (a, b, c, filler1)
|
INSERT INTO mcv_lists (a, b, c, filler1)
|
||||||
SELECT mod(i,37), mod(i,41), mod(i,43), mod(i,47) FROM generate_series(1,5000) s(i);
|
SELECT mod(i,37), mod(i,41), mod(i,43), mod(i,47) FROM generate_series(1,5000) s(i);
|
||||||
|
|
||||||
VACUUM (ANALYZE) mcv_lists;
|
ANALYZE mcv_lists;
|
||||||
|
|
||||||
SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''');
|
SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''');
|
||||||
|
|
||||||
@ -476,7 +482,7 @@ DROP STATISTICS mcv_lists_stats;
|
|||||||
INSERT INTO mcv_lists (a, b, c, filler1)
|
INSERT INTO mcv_lists (a, b, c, filler1)
|
||||||
SELECT mod(i,100), mod(i,50), mod(i,25), i FROM generate_series(1,5000) s(i);
|
SELECT mod(i,100), mod(i,50), mod(i,25), i FROM generate_series(1,5000) s(i);
|
||||||
|
|
||||||
VACUUM (ANALYZE) mcv_lists;
|
ANALYZE mcv_lists;
|
||||||
|
|
||||||
SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''');
|
SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''');
|
||||||
|
|
||||||
@ -589,7 +595,7 @@ ALTER TABLE mcv_lists ALTER COLUMN c TYPE numeric;
|
|||||||
|
|
||||||
SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''');
|
SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''');
|
||||||
|
|
||||||
VACUUM (ANALYZE) mcv_lists;
|
ANALYZE mcv_lists;
|
||||||
|
|
||||||
SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''');
|
SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''');
|
||||||
|
|
||||||
@ -605,7 +611,7 @@ INSERT INTO mcv_lists (a, b, c, filler1)
|
|||||||
i
|
i
|
||||||
FROM generate_series(1,5000) s(i);
|
FROM generate_series(1,5000) s(i);
|
||||||
|
|
||||||
VACUUM (ANALYZE) mcv_lists;
|
ANALYZE mcv_lists;
|
||||||
|
|
||||||
SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND b IS NULL');
|
SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND b IS NULL');
|
||||||
|
|
||||||
@ -635,7 +641,8 @@ SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IN (0, 1) AN
|
|||||||
-- test pg_mcv_list_items with a very simple (single item) MCV list
|
-- test pg_mcv_list_items with a very simple (single item) MCV list
|
||||||
TRUNCATE mcv_lists;
|
TRUNCATE mcv_lists;
|
||||||
INSERT INTO mcv_lists (a, b, c) SELECT 1, 2, 3 FROM generate_series(1,1000) s(i);
|
INSERT INTO mcv_lists (a, b, c) SELECT 1, 2, 3 FROM generate_series(1,1000) s(i);
|
||||||
VACUUM (ANALYZE) mcv_lists;
|
ANALYZE mcv_lists;
|
||||||
|
|
||||||
SELECT m.*
|
SELECT m.*
|
||||||
FROM pg_statistic_ext s, pg_statistic_ext_data d,
|
FROM pg_statistic_ext s, pg_statistic_ext_data d,
|
||||||
pg_mcv_list_items(d.stxdmcv) m
|
pg_mcv_list_items(d.stxdmcv) m
|
||||||
@ -654,7 +661,7 @@ INSERT INTO mcv_lists (a, b, c, d)
|
|||||||
(CASE WHEN mod(i,2) = 0 THEN NULL ELSE 'x' END)
|
(CASE WHEN mod(i,2) = 0 THEN NULL ELSE 'x' END)
|
||||||
FROM generate_series(1,5000) s(i);
|
FROM generate_series(1,5000) s(i);
|
||||||
|
|
||||||
VACUUM (ANALYZE) mcv_lists;
|
ANALYZE mcv_lists;
|
||||||
|
|
||||||
SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE b = ''x'' OR d = ''x''');
|
SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE b = ''x'' OR d = ''x''');
|
||||||
|
|
||||||
@ -685,7 +692,8 @@ CREATE TABLE mcv_lists_uuid (
|
|||||||
a UUID,
|
a UUID,
|
||||||
b UUID,
|
b UUID,
|
||||||
c UUID
|
c UUID
|
||||||
);
|
)
|
||||||
|
WITH (autovacuum_enabled = off);
|
||||||
|
|
||||||
INSERT INTO mcv_lists_uuid (a, b, c)
|
INSERT INTO mcv_lists_uuid (a, b, c)
|
||||||
SELECT
|
SELECT
|
||||||
@ -716,7 +724,8 @@ CREATE TABLE mcv_lists_arrays (
|
|||||||
a TEXT[],
|
a TEXT[],
|
||||||
b NUMERIC[],
|
b NUMERIC[],
|
||||||
c INT[]
|
c INT[]
|
||||||
);
|
)
|
||||||
|
WITH (autovacuum_enabled = off);
|
||||||
|
|
||||||
INSERT INTO mcv_lists_arrays (a, b, c)
|
INSERT INTO mcv_lists_arrays (a, b, c)
|
||||||
SELECT
|
SELECT
|
||||||
@ -735,14 +744,15 @@ CREATE TABLE mcv_lists_bool (
|
|||||||
a BOOL,
|
a BOOL,
|
||||||
b BOOL,
|
b BOOL,
|
||||||
c BOOL
|
c BOOL
|
||||||
);
|
)
|
||||||
|
WITH (autovacuum_enabled = off);
|
||||||
|
|
||||||
INSERT INTO mcv_lists_bool (a, b, c)
|
INSERT INTO mcv_lists_bool (a, b, c)
|
||||||
SELECT
|
SELECT
|
||||||
(mod(i,2) = 0), (mod(i,4) = 0), (mod(i,8) = 0)
|
(mod(i,2) = 0), (mod(i,4) = 0), (mod(i,8) = 0)
|
||||||
FROM generate_series(1,10000) s(i);
|
FROM generate_series(1,10000) s(i);
|
||||||
|
|
||||||
VACUUM (ANALYZE) mcv_lists_bool;
|
ANALYZE mcv_lists_bool;
|
||||||
|
|
||||||
SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE a AND b AND c');
|
SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE a AND b AND c');
|
||||||
|
|
||||||
@ -771,7 +781,8 @@ CREATE TABLE mcv_lists_multi (
|
|||||||
b INTEGER,
|
b INTEGER,
|
||||||
c INTEGER,
|
c INTEGER,
|
||||||
d INTEGER
|
d INTEGER
|
||||||
);
|
)
|
||||||
|
WITH (autovacuum_enabled = off);
|
||||||
|
|
||||||
INSERT INTO mcv_lists_multi (a, b, c, d)
|
INSERT INTO mcv_lists_multi (a, b, c, d)
|
||||||
SELECT
|
SELECT
|
||||||
|
Loading…
Reference in New Issue
Block a user