简体   繁体   English

DB2 LUW 表在读取时被锁定

[英]DB2 LUW table locked while reading

I have a range partitioned table in my database, it is range partitioned by a date column: transaction_date, with 1 partition per 1 month.我的数据库中有一个范围分区表,它按日期列进行范围分区:transaction_date,每 1 个月有 1 个分区。

Now my problem is: When running SQL statement to read data from the table,现在我的问题是:当运行 SQL 语句从表中读取数据时,

select col1,col2 from mytable where ID=1

My table is very large so it takes a long time for the SQL to finish.我的表非常大,所以 SQL 需要很长时间才能完成。 However, there is another ETL job to insert (append) data to the table at the same time, the insert operation cannot start until the read SQL finishes.但是,同时还有另一个ETL作业向表中插入(追加)数据,直到读取SQL完成后,插入操作才能开始。

Any suggestions I can avoid this issue while reading data?有什么建议我可以在阅读数据时避免这个问题吗? Also are there any IBM official documents regarding this problem?是否还有关于此问题的任何 IBM 官方文档?

** EDIT 1: ** 编辑 1:

$ db2level
DB21085I  This instance or install (instance name, where applicable:
"db2inst1") uses "64" bits and Db2 code release "SQL11011" with level
identifier "0202010F".

Informational tokens are "DB2 v11.1.1.1", "s1610100100", 
"DYN1610100100AMD64", and Fix Pack "1".

Product is installed at "/opt/ibm/db2/v11.1". 

$ db2set -all
[i] DB2COMM=TCPIP
[i] DB2AUTOSTART=TRUE
[i] DB2OPTIONS=+c
[g] DB2FCMCOMM=TCPIP4
[g] DB2SYSTEM=<server hostname>
[g] DB2INSTDEF=db2inst1

** EDIT 2: ** 编辑 2:

For the select and load SQL statement, I am not specifying any isolation level.对于 select 和 load SQL 语句,我没有指定任何隔离级别。

For the ETL job, it is an IBM DataStage job, the ETL insert is a bulk load append operation to insert data to a pre-existing range.对于 ETL 作业,它是一个 IBM DataStage 作业,ETL 插入是一个批量加载附加操作,用于将数据插入到预先存在的范围中。

You may use the MON_LOCKWAITS administrative view to check what's happening during such a lock situation.您可以使用MON_LOCKWAITS 管理视图来检查在这种锁定情况下发生了什么。 You may optionally format a lock with the MON_FORMAT_LOCK_NAME function to get more details on this as well.您也可以选择使用MON_FORMAT_LOCK_NAME函数格式化锁以获取更多详细信息。

SELECT 
  W.*
--, F.NAME, F.VALUE
FROM SYSIBMADM.MON_LOCKWAITS W
--, TABLE(MON_FORMAT_LOCK_NAME(W.LOCK_NAME)) F
--WHERE W.REQ_APPLICATION_HANDLE = XXX -- if you know the holder's handle to reduce the amount of data returned
ORDER BY W.LOCK_NAME
;

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

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