467,135 Members | 1,195 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,135 developers. It's quick & easy.

Cancel query based on a timeout

Hi List,

I'm running a query on a not-so-small db. Mostly this query runs fast enough, but every once in a while the query takes a long time to complete in wich case the users start banging away on the keyboard :-).

What we would like to do is cancel the query after a certain time-out (e.g.30 sec.)
Is there some way to send a command to the postgres sever to stop running the query?

We're using Postgres 7.3.4 and the latest ODBC driver. Programming is done with Borland Delphi 7
Regards,

Stijn Vanroye

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #1
  • viewed: 3130
Share:
3 Replies
Stijn Vanroye wrote:
Hi List,

I'm running a query on a not-so-small db. Mostly this query runs fast enough, but every once in a while the query takes a long time to complete in wich case the users start banging away on the keyboard :-).

What we would like to do is cancel the query after a certain time-out (e.g. 30 sec.)
Is there some way to send a command to the postgres sever to stop running the query?

We're using Postgres 7.3.4 and the latest ODBC driver. Programming is done with Borland Delphi 7


AFAIK, there is a statement timeout option but exactly which version brought it
in escapes me ATM...Most probably 7.4.x but don't take my word for it. Check you
r postgrersql.conf for details.

HTH

Shridhar

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #2
"Stijn Vanroye" <s.*******@farcourier.com> writes:
Is there some way to send a command to the postgres sever to stop running the query?


There's a statement_timeout parameter in recent releases. I forget
whether 7.3 has it though...

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #3
Hi,

We are working on a similar problem - timeouts of long-running requests. We
are also currently using 7.3.4 for Postgres, but we are using Java, JDBC,
and PL/PGSql.

Question: Does Delphi have structured exception-handling? The solution
we've found requires the ability to descriminate between exception-types and
the ability to catch and throw execeptions in a safe fashion. If Delphi
does have SHE, then I think our solution could be mapped into Delphi without
much trouble.

The solution we've come up with is to add a "waiting procedure" table to the
database, along with some stored-procedures to manage the table. We call
this the "waitingproc" subsystem.

The "waitingproc" subsystem can then be used by client-side code (thru JDBC
calls; ODBC should be able to handle the particular subset we are dealing
with here) to detect when a server-side process overruns its alloted time.
The client then has the option to abort the transaction and/or restart the
server-side process.

Of course, the problem we are throwing the "waitingproc" subsystem at is not
your problem, but I think some of the core concepts/procedures are usuable.

Let me know if you'd like the Java and PL/PGSql source. The Java code is
fairly extensive and is mixed in with other business-logic, but I can help
you thru the rough parts.

Carl <|};-)>
-----Original Message-----
From: pg*****************@postgresql.org
[mailto:pg*****************@postgresql.org] On Behalf Of Stijn Vanroye
Sent: Monday, May 10, 2004 3:55 AM
To: pg***********@postgresql.org
Subject: [GENERAL] Cancel query based on a timeout
Hi List,

I'm running a query on a not-so-small db. Mostly this query runs fast
enough, but every once in a while the query takes a long time to complete in
wich case the users start banging away on the keyboard :-).

What we would like to do is cancel the query after a certain time-out (e.g.
30 sec.) Is there some way to send a command to the postgres sever to stop
running the query?

We're using Postgres 7.3.4 and the latest ODBC driver. Programming is done
with Borland Delphi 7
Regards,

Stijn Vanroye

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by The Whistler | last post: by
2 posts views Thread by Robinson | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.