Generate stats used to identify category columns in overviews if needed
This only generates the stats if no stats are available for a table. This doesn't warrant that the stats are up to date or accurate.
This commit is contained in:
parent
2c43943df6
commit
a067cc7da1
@ -557,10 +557,20 @@ AS $$
|
|||||||
DECLARE
|
DECLARE
|
||||||
schema_name TEXT;
|
schema_name TEXT;
|
||||||
table_name TEXT;
|
table_name TEXT;
|
||||||
|
available BOOLEAN;
|
||||||
categorical BOOLEAN;
|
categorical BOOLEAN;
|
||||||
BEGIN
|
BEGIN
|
||||||
SELECT * FROM _cdb_split_table_name(reloid) INTO schema_name, table_name;
|
SELECT * FROM _cdb_split_table_name(reloid) INTO schema_name, table_name;
|
||||||
SELECT n_distinct IS NOT NULL AND n_distinct > 0 AND n_distinct <= 20
|
SELECT n_distinct IS NOT NULL
|
||||||
|
FROM pg_stats
|
||||||
|
WHERE pg_stats.schemaname = schema_name
|
||||||
|
AND pg_stats.tablename = table_name
|
||||||
|
AND pg_stats.attname = col_name
|
||||||
|
INTO available;
|
||||||
|
IF available IS NULL OR NOT available THEN
|
||||||
|
EXECUTE Format('ANALYZE %s;', reloid);
|
||||||
|
END IF;
|
||||||
|
SELECT n_distinct > 0 AND n_distinct <= 20
|
||||||
FROM pg_stats
|
FROM pg_stats
|
||||||
WHERE pg_stats.schemaname = schema_name
|
WHERE pg_stats.schemaname = schema_name
|
||||||
AND pg_stats.tablename = table_name
|
AND pg_stats.tablename = table_name
|
||||||
@ -568,7 +578,7 @@ BEGIN
|
|||||||
INTO categorical;
|
INTO categorical;
|
||||||
RETURN categorical;
|
RETURN categorical;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE PLPGSQL STABLE;
|
$$ LANGUAGE PLPGSQL VOLATILE;
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION _cdb_mode_of_array(anyarray)
|
CREATE OR REPLACE FUNCTION _cdb_mode_of_array(anyarray)
|
||||||
RETURNS anyelement AS
|
RETURNS anyelement AS
|
||||||
|
Loading…
Reference in New Issue
Block a user