db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pavel Bortnovskiy <PBortnovs...@Jefferies.com>
Subject Can it be that Derby (in-memory) is deadlocking on this query?
Date Thu, 20 Jan 2011 18:28:56 GMT
Hello:

while running my application, I noticed that when the following query 
(which uses a subquery with tables joining on themselves) is executed, the 
application processes 185 records and then sits indefinitely in 
ResultSet.next() method:

SELECT 
    P1.ID ,
    R1.description
    P1.BOOK
    P1.NOMINAL
    P1.NOMINAL * R1.Factor
FROM
    P_TABLE P1,
    R_TABLE R1,
    (
      select 
        R2.IN_ID
      from 
        P_TABLE P2,
        R_TABLE R2
      where 
        P2.IN_ID = R2.IN_ID AND
        P2.NOMINAL <> 0  AND
        R2.IType='X'
      GROUP BY R2.IN_ID 
      HAVING COUNT(*) >1
    ) as MULTI
WHERE
    P1.IN_ID = R1.IN_ID  AND
    MULTI.IN_ID = R1.IN_ID


Then I tried running AquaDataStudio with this query and it's been over 16 
minutes without any results back:



However, when I run the subquery itself, it executes practically 
instanteneously:



And if I replace the subquery with where R1.IN in ('P32764', 'P32765', ... 
[all results from subquery]), it executes in a few ms:



I have a suspicion that Derby (which is running in in-memory only mode) is 
deadlocking.
What can I do on my end (without exposing our data) to help you diagnose 
this.

Please respond as soon as you can, since this is quite important and 
urgent.

Thank you,
Pavel.




Jefferies archives and monitors outgoing and incoming e-mail. The contents of this email,
including any attachments, are confidential to the ordinary user of the email address to which
it was addressed. If you are not the addressee of this email you may not copy, forward, disclose
or otherwise use it or any part of it in any form whatsoever. This email may be produced at
the request of regulators or in connection with civil litigation. Jefferies accepts no liability
for any errors or omissions arising as a result of transmission. Use by other than intended
recipients is prohibited.  In the United Kingdom, Jefferies operates as Jefferies International
Limited; registered in England: no. 1978621; registered office: Vintners Place, 68 Upper Thames
Street, London EC4V 3BJ.  Jefferies International Limited is authorised and regulated by the
Financial Services Authority.
Mime
View raw message