建议2

有这样的一个需求,假如有表 t (100w条数据) ; 需要使用它不同的部分各自的统计分析:

a = select * from t where t1 > 0 ; statistic_a(a)

b = select * from t where t2 > 0 ; statistic_b(b)

c = select * from t where t3 > 0 ; statistic_c(c)


如果直接使用表 t 来做统计,不同统计函数里的所有计算都要加上 where tn > 0  ,会拖慢统计速度;如果所有部分数据都先查出来,再各自统计,select 生成新表时的数据拷贝也会耗费较多时间;

是否能像 python 的 dataframe 那样,使用类似 &a = select * from t where t1 > 0 方法定义一个 t 表的引用,后续就可以在 a 的基础上进行计算;

请先 登录 后评论

1 个回答

Polly

内部是支持 &a 这种写法表示引用的


请先 登录 后评论
  • 1 关注
  • 0 收藏,271 浏览
  • Mkelar 提出于 2024-01-17 18:08

相似问题