snowflake sproc vs standalone sql

允我心安 提交于 2019-12-24 21:30:41

问题


I am thinking to create denormalized table for our BI purpose.

While creating business logic from several tables i noticed queries perform better when denormalized table is updated in batches(sproc with multiple business logic SQL's) with merge statement as below.

eg: sproc contains multiple SQL's like

  1. merge denormalized_data (select businesslogic1)
  2. merge denormalized_data (select businesslogic2)
    etc

Is it better to include business logic in huge SQL or divide it so that each query handles less number of rows?

Is there any overhead if I use sproc?


回答1:


Speaking very generally. Snowflake is optimized to work in large batches. For example, I've had cases where it takes about as long to insert 1 record as 100,000 records. So inserting 1 record 100,000 times is a LOT slower.

There is certainly going to be some limit. A 1TB batch should be split up. And your mileage may vary depending on how/when/etc. you are updating the table. In general though, you'll find batches are more performant.

The only real overhead that I know of for procedures has to do with converting data types from SQL to Javascript and back again, and then how you have to manage the output. In most cases, this won't be significant.



来源:https://stackoverflow.com/questions/59147564/snowflake-sproc-vs-standalone-sql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!