【Caused by】Vertica error - too complex to analyze

4 篇文章 0 订阅
1 篇文章 0 订阅

2018.11.30

前言

某工程进行Vertica表间数据拼接,大致SQL语句如下:

insert into tableForInsert as select * from tableA union all select * from tableB ...

union all1的表非常多,导致SQL语句过长,报错如下:

java.sql.SQLNonTransientException: [Vertica][VJDBC](4963) ERROR: The query contains a SET operation tree that is too complex to analyze

追根溯源

从Vertica的官方文档2得知,Vertica对于SQL语句有两条限制:
Vertica Limits to SQL Expressions

  1. The first limit is based on the stack available to the expression. Vertica requires at least 100kb of free stack:第一条是关于SQL语句的大小,要求小于栈大小。这取决于Vertica的配置;
  2. The second limit is the number of recursions possible in an analytic expression. The limit is 2000…cannot be increased:第二条是语句可能的递归次数不得超过2000,而且2000是上限,不可增加。

并且根据Vertica官方某博客3可推断,union all是一条递归语句:

Other implementations include ANSI SQL’s recursive SQL syntax using WITH and UNION ALL, special graph based algorithms and enumerated path technique

恍然大悟

综上,该语句报错的原因就是SQL语句的union all太多而导致超过2000的上限。最佳解决方案是修改SQL语句,弃用union all进行拼接,根本上避免了会超过上限的可能性;次之的方法,可以考虑将SQL语句缩短。


  1. Vertica Union Clause ↩︎

  2. Vertica Limits to SQL Expressions ↩︎

  3. Can Vertica Climb a Tree? ↩︎

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值