sbb
sbb

Reputation: 569

Is it possible to set a query timeout for slick-hikaricp?

I have a play-scala application which uses slick-hikaricp. I know there is way to set connection timeout but I would like to set a query timeout. I have some slow queries and if they take more than 3 seconds I would like to stop them with timeout setting. I searched and bonecp provides a parameter named as 'queryExecuteTimeLimit' but I couldn't find a setting for hikaricp. Do you know how can I set a query timeout?

Upvotes: 2

Views: 1935

Answers (1)

Mario Galic
Mario Galic

Reputation: 48410

Have you tried using Slick's withStatementParameters to setQueryTimeout? For example,

myTable.result.withStatementParameters(statementInit = _.setQueryTimeout(3))

This should throw SQLTimeoutException if query takes longer than 3 seconds.

Upvotes: 5

Related Questions