Avoid aggregation which causes out-of-memory crashes in PostgreSQL
The use of multiple string_agg functions, even if applied to groups of one single record causes out of memory crashes in PG 9.3.4 for some (large) tables.
This commit is contained in:
@@ -463,7 +463,9 @@ BEGIN
|
|||||||
-- 'A', 'B', 'A', 'C', 'D' => 'A/B/C/...'
|
-- 'A', 'B', 'A', 'C', 'D' => 'A/B/C/...'
|
||||||
-- Other ideas: if value is unique then use it, otherwise use something
|
-- Other ideas: if value is unique then use it, otherwise use something
|
||||||
-- like '*' or '(varies)' or '(multiple values)', or NULL
|
-- like '*' or '(varies)' or '(multiple values)', or NULL
|
||||||
RETURN 'CASE count(*) WHEN 1 THEN string_agg(' || qualified_column || ',''/'') ELSE ''*''' || ' END::' || column_type;
|
-- Using 'string_agg(' || qualified_column || ',''/'')'
|
||||||
|
-- here causes
|
||||||
|
RETURN 'CASE count(*) WHEN 1 THEN MIN(' || qualified_column || ') ELSE NULL END::' || column_type;
|
||||||
ELSE
|
ELSE
|
||||||
RETURN 'CASE count(*) WHEN 1 THEN MIN(' || qualified_column || ') ELSE NULL END::' || column_type;
|
RETURN 'CASE count(*) WHEN 1 THEN MIN(' || qualified_column || ') ELSE NULL END::' || column_type;
|
||||||
END CASE;
|
END CASE;
|
||||||
|
|||||||
Reference in New Issue
Block a user