创建一个由几个表组成的 UNION 视图

Creating a View that is a UNION of a few tables

我的一个客户想要创建一个 UNION 几个表的视图。

来自客户:

These tables are populated by streaming data sources and are pretty sizable already. Because of how the set operations get applied, any queries of this view are causing performance issues, since any filters/predicates get applied after the UNIONs. I know that you can’t materialize a view with UNION operations, so I was wondering if Snowflake recommends any other solution short of building a separate table which unions the constituent tables.

我按如下方式创建了一个视图,并且在 UNION 之前按预期进行了修剪。

我想知道他们的问题是由于 UNION(具有重复数据删除的性能损失)还是 UNION ALL

create or replace view test_unions
(
  mycol1,
  mycol2,
  mycol3
) as (
  (select mycol1,mycol2,mycol3 from tableA)
  union all (select  mycol1,mycol2,mycol3 from tableB)
  union all (select  mycol1,mycol2,mycol3 from tableC)
)
;