我真的很感激一些幫助這裏。 我已經從我的客戶得到這個Derby數據庫及其應用基於Hibernate。我不能讓它工作,因爲Hibernate生成查詢掛斷整個數據庫:的Apache Derby掛斷執行查詢
select houses0_.STREET_ID as STREET5_1_, houses0_.ID as ID1_, houses0_.ID as ID42_0_, houses0_.NAME as NAME42_0_, houses0_.SHORT_NAME as SHORT3_42_0_, houses0_.INDEX as INDEX42_0_ from SRG.HOUSE_REFERENCE houses0_ where houses0_.STREET_ID in (select streets0_.ID from SRG.STREET_REFERENCE streets0_ where streets0_.TOWNSHIP_ID in (select townships0_.ID from SRG.TOWNSHIP_REFERENCE townships0_ where townships0_.CITY_ID='555'))
我沒有看到任何東西在它可疑的,但是當我用它推出德比 - 德比只是什麼都不做。這裏是我的日誌:
2011-10-31 21:58:10.328 GMT Thread[DRDAConnThread_3,5,main] (XID = 1152939), (SESSIONID = 1), (DATABASE = dev), (DRDAID = NF000001.FC97-434877518919679629{1}), Begin compiling prepared statement: select houses0_.STREET_ID as STREET5_1_, houses0_.ID as ID1_, houses0_.ID as ID42_0_, houses0_.NAME as NAME42_0_, houses0_.SHORT_NAME as SHORT3_42_0_, houses0_.INDEX as INDEX42_0_ from HOUSE_REFERENCE houses0_ where houses0_.STREET_ID in (select streets0_.ID from STREET_REFERENCE streets0_ where streets0_.TOWNSHIP_ID in (select townships0_.ID from TOWNSHIP_REFERENCE townships0_ where townships0_.CITY_ID='555')) :End prepared statement
2011-10-31 21:58:10.682 GMT Thread[DRDAConnThread_3,5,main] (XID = 1152939), (SESSIONID = 1), (DATABASE = dev), (DRDAID = NF000001.FC97-434877518919679629{1}), End compiling prepared statement: select houses0_.STREET_ID as STREET5_1_, houses0_.ID as ID1_, houses0_.ID as ID42_0_, houses0_.NAME as NAME42_0_, houses0_.SHORT_NAME as SHORT3_42_0_, houses0_.INDEX as INDEX42_0_ from SRG.HOUSE_REFERENCE houses0_ where houses0_.STREET_ID in (select streets0_.ID from SRG.STREET_REFERENCE streets0_ where streets0_.TOWNSHIP_ID in (select townships0_.ID from SRG.TOWNSHIP_REFERENCE townships0_ where townships0_.CITY_ID='555')) :End prepared statement
2011-10-31 21:58:10.758 GMT Thread[DRDAConnThread_3,5,main] (XID = 1152939), (SESSIONID = 1), (DATABASE = dev), (DRDAID = NF000001.FC97-434877518919679629{1}), Executing prepared statement: select houses0_.STREET_ID as STREET5_1_, houses0_.ID as ID1_, houses0_.ID as ID42_0_, houses0_.NAME as NAME42_0_, houses0_.SHORT_NAME as SHORT3_42_0_, houses0_.INDEX as INDEX42_0_ from SRG.HOUSE_REFERENCE houses0_ where houses0_.STREET_ID in (select streets0_.ID from SRG.STREET_REFERENCE streets0_ where streets0_.TOWNSHIP_ID in (select townships0_.ID from SRG.TOWNSHIP_REFERENCE townships0_ where townships0_.CITY_ID='555')) :End prepared statement
然後什麼都沒有。 我設置一些屬性:
derby.drda.portNumber=1529
derby.locks.deadlockTrace=true
derby.locks.monitor=true
derby.locks.deadlockTimeout=1
derby.locks.waitTimeout=1
derby.language.logStatementText=false
derby.infolog.append=true
derby.stream.error.logSeverityLevel=0
derby.drda.logConnections=true
derby.language.logStatementText=true
derby.language.logQueryPlan=true
看看怎麼回事,但有沒有在日誌中,這個查詢只需要永恆的執行,無論是其從休眠或squirrelsql或Derby的ij工具來完成。 正如你可以看到超時是非常小,但德比犯規停止執行查詢時,它留下它做任何查詢想要的。
查詢不是那麼複雜 - 我用它連接改寫了,花了1秒執行。但不是這種形式 - 我沒有明白,爲什麼?你能給我任何提示嗎?
UPD:house_reference包含7508行,選擇從*花費house_reference小於第二,street_reference包含〜44K行,並且子查詢
select streets0_.ID from STREET_REFERENCE streets0_ where streets0_.TOWNSHIP_ID in (select townships0_.ID from TOWNSHIP_REFERENCE townships0_ where townships0_.CITY_ID='52000001000')
返回111行,在不到一秒鐘。所以選擇從* house_reference在含有111行子句需要分鐘來執行,並將其返回0的結果。這對我來說看起來不錯,但我沒有在數據庫管理方面經歷過的判斷,這就是爲什麼我要求社區:)
它不是一個解決辦法了豐富的德比調整指南中的信息,因爲我不是不允許修改的客戶代碼這個特定部分。我重新編寫它只是爲了檢查一切是否適合表格,而且它們不是太大。我問的是:爲什麼德比在超時後停止這個查詢?爲什麼不把執行計劃寫入日誌文件?爲什麼德比在被執行的時候對它做了什麼? – Anton
我不確定。你什麼意思是超時? derby.locks.deadlockTimeout和derby.locks。waitTimeout必須處理獨立事務之間的併發控制,而不是在需要很長時間運行的查詢上停止執行。 –
哦。這是我迄今爲止設置的唯一一個超時。這是有道理的,但執行時間非常巨大。 – Anton