English 中文(简体)
删除
原标题:Executing Insert Statements in Parallel in Snowflake

我有一个储存程序,执行3个insert/select,在Snowflake3个不同表格中填写了3个表格:附表Union、附表Union1、附表Union2。 现在,由于每次发言要完成的时间,也就是要在执行发言的同时,缩短总体执行时间。 为此,Im试图利用Promise.all。 我不想在这里张贴所有发言稿,但这一样本很好地反映了我为什么要这样做:

CREATE OR REPLACE procedure etl."JimTest" ()
RETURNS VARCHAR
LANGUAGE JAVASCRIPT 
AS
$$

   async function runSQL(sqlarray) {

   snowflake.execute({ sqlText: sqlarray.sqltask } );
  }

   async function executeQuery() {

    sql1 = `INSERT into ScheduleUnion Select.....`
    sql2 = `INSERT into ScheduleUnion1 Select.....`
    sql3 = `INSERT into ScheduleUnion2 Select.....`

     const queries = [
        {sqltask: sql1},
        {sqltask: sql2},
        {sqltask: sql3}
    ];

    const sqlTasks = queries.map(runSQL);

    await Promise.all(sqlTasks); 
 }

  executeQuery();

  return  done ;
$$

然而,我仍然看到我以连续方式插入一份声明:

“entergraph

是否有

问题回答

Might be a bit late, but better late than never:

Javascript parallelism within a single session is disabled in Snowflake. Therefore, regardless of any attempts to force asynchronous thread launch from within a Snowflake stored procedure, all calls will execute sequentially. In the OPs case, the .map() call will generate promises, and Promise.all() will wait for them all to resolve. But the underlying engine will not behave in a multithreaded fashion, so it s all pointless.

In order to perform multi-threaded parallel operations, one must use an external client -- e.g. an ETL tool -- which launches independent session threads in parallel, via an external driver. Both Talend and Matillion are readily capable of doing this. I would recommend Matillion, as it is easier to use and has a simpler deployment architecture.

A Snowflake warehouse is an MPP system that will schedule and execute commands in its queue based on the available processing capacity it has - you can t force it to run anything in parallel and it run will/may differ depending on resources available at run-time (i.e. what else is running).

如果问询速度不够快,你至少可以有2个斯诺瓦特特征:

  1. Increase the size of the warehouse you are using
  2. Run each query with a different warehouse

鉴于Snowflake允许所有这些物品都作包装,在你的印本开始时,你可以增加你的仓库面积(或建立/启动其他仓库),在你的印本结束时,你可以减少你的仓库面积(或关闭其他仓库)。

任务可以用来同时 st。

由于任务可以重叠的方式:

ALLOW_OVERLAPPING_EXECUTION = TRUE | FALSE

https://docs.snowflake.com/en/user-guide/tasks-intro.html#overlapping-dag-runs https://docs.snowflake.com/en/sql-reference/sql/create-task.html#syntax

You can create a procedure that does the insert, then create a task that runs that procedure. In your main function you can execute the task multiple times. The execute task command doesn t wait for the task to end, it runs in the background.

也可以通过询问 * 资料_schema.task_history,等到他们完成学业/失败等,来监测正在完成的任务。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签