• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Replacing setQueryTimeout(int timeoutValue)

 
Serkan Demir
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

Many of you may use setQueryTimeout(int timeoutValue) method of PreparedStatement object for limiting the query time. This method internally creates a Timer thread, start it whenever query starts and stop and garbage it whenever query finishes. This is a useful method and prevents suspended threads which are waiting the query results.

However, our system needs high performance and responds more than 1000 request per second by querying database. Whenever i use setQueryTimeout method for each query, the amount of responses per second decreases and CPU usage increases (thread creation, starting are very expensive and I/O bound). Therefore i want to tune my application and by the way searching a replacement for setQueryTimeout method.

Is there anyone who comes with an idea?
 
Scott Selikoff
author
Saloon Keeper
Posts: 4007
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try figuring out why you need to call setQueryTimeout() in the first place. Chances are it is a locking issue of some kind. Better transaction management and/or foreign key indexes, may vastly decrease locking such that the call is not needed.
 
Serkan Demir
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have a worker pool which are only responsible for database transactions. Rarely, some workers are suspended while they are querying DB. I dont know the reason behind this suspension but it happens. Thus, we need to set some waiting limits for these suspended threads.
The reason for this query timeout is basically this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic