Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/backend/commands/analyze.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,8 +717,10 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
* statistics target. So we may need to sample more rows and then build
* the statistics with enough detail.
*/
minrows = ComputeExtStatisticsRows(onerel, attr_cnt, vacattrstats);

if (IS_QD_OR_SINGLENODE())
minrows = ComputeExtStatisticsRows(onerel, attr_cnt, vacattrstats);
else
minrows = 0;

if (targrows < minrows)
targrows = minrows;
Expand Down
13 changes: 13 additions & 0 deletions src/test/regress/expected/stats_ext.out
Original file line number Diff line number Diff line change
Expand Up @@ -3240,3 +3240,16 @@ NOTICE: drop cascades to 2 other objects
DETAIL: drop cascades to table tststats.priv_test_tbl
drop cascades to view tststats.priv_test_view
DROP USER regress_stats_user1;
-- test analyze with extended statistics
CREATE TABLE tbl_issue1293 (col1 int, col2 int);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'col1' as the Apache Cloudberry data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
INSERT INTO tbl_issue1293
SELECT i / 10000, i / 100000
FROM generate_series(1, 1000000) s(i);
ANALYZE tbl_issue1293;
-- Create extended statistics on col1, col2
CREATE STATISTICS s1 (dependencies) ON col1, col2 FROM tbl_issue1293;
-- Trigger extended stats collection
ANALYZE tbl_issue1293;
DROP TABLE tbl_issue1293;
13 changes: 13 additions & 0 deletions src/test/regress/expected/stats_ext_optimizer.out
Original file line number Diff line number Diff line change
Expand Up @@ -3275,3 +3275,16 @@ NOTICE: drop cascades to 2 other objects
DETAIL: drop cascades to table tststats.priv_test_tbl
drop cascades to view tststats.priv_test_view
DROP USER regress_stats_user1;
-- test analyze with extended statistics
CREATE TABLE tbl_issue1293 (col1 int, col2 int);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'col1' as the Apache Cloudberry data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
INSERT INTO tbl_issue1293
SELECT i / 10000, i / 100000
FROM generate_series(1, 1000000) s(i);
ANALYZE tbl_issue1293;
-- Create extended statistics on col1, col2
CREATE STATISTICS s1 (dependencies) ON col1, col2 FROM tbl_issue1293;
-- Trigger extended stats collection
ANALYZE tbl_issue1293;
DROP TABLE tbl_issue1293;
12 changes: 12 additions & 0 deletions src/test/regress/sql/stats_ext.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1651,3 +1651,15 @@ DROP FUNCTION op_leak(int, int);
RESET SESSION AUTHORIZATION;
DROP SCHEMA tststats CASCADE;
DROP USER regress_stats_user1;

-- test analyze with extended statistics
CREATE TABLE tbl_issue1293 (col1 int, col2 int);
INSERT INTO tbl_issue1293
SELECT i / 10000, i / 100000
FROM generate_series(1, 1000000) s(i);
ANALYZE tbl_issue1293;
-- Create extended statistics on col1, col2
CREATE STATISTICS s1 (dependencies) ON col1, col2 FROM tbl_issue1293;
-- Trigger extended stats collection
ANALYZE tbl_issue1293;
DROP TABLE tbl_issue1293;
Loading