简体   繁体   English

Teradata多个连接INSERT死锁

[英]Teradata multiple connections INSERT deadlock

I create multiple connections and make batch inserts into myTable simultaneously (multi threading) 我创建多个连接,并同时将批量插入myTable中(多线程)

insertString = "INSERT INTO ... + values + ") "; 
insertTable.addBatch(insertString); 
insertTable.executeBatch();
insertTable.clearBatch(); 

Sometime it works fine, however in other cases it hangs. 有时它可以正常工作,但是在其他情况下则挂起。 I understand this is because I am inserting into the same table so it gets locked . 我知道这是因为我要插入同一张表,所以它被锁定了。

How can I write an INSERT statement such that it does not lock the table? 如何编写一个INSERT语句,使其不锁定表?

Are there any special transaction start . . 是否有任何特殊的transaction start . . transaction start . . commands that can prevent the table from being locked ? 可以防止表被锁定的命令? In addition, I am curious why it works fine sometimes ? 另外,我很好奇为什么有时还能正常工作?

PS: the maximum number of connections that I used was 1024 (worked perfect sometimes) PS:我使用的最大连接数为1024(有时工作正常)

Thanks 谢谢

1024 session is totally insane. 1024会话完全是疯狂的。 Your DBA should block your user for that. 为此,您的DBA应该阻止您的用户。

You probably get blocked sessions when you load multiple rows with the same PI. 使用相同的PI加载多行时,您可能会遇到阻塞的会话。

Single-row INSERTs are the slowest way to load data. 单行INSERT是最慢的数据加载方式。 A single session with a batch size of a few 1000 will outperform dozens of single-row sessions (but then only use one session). 批量为几千个的单个会话将胜过数十个单行会话(但随后仅使用一个会话)。

Or switch to JDBC FastLoad if the target table is empty. 或如果目标表为空,则切换到JDBC FastLoad。

Check http://developer.teradata.com/connectivity/articles/speed-up-your-jdbcodbc-applications 检查http://developer.teradata.com/connectivity/articles/speed-up-your-jdbcodbc-applications

Is this a staging table? 这是登台桌吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM