"Arguile" <arguile@lucentstudios.com> writes:
> I'm currently pursuing a line of thought on resource limiting, and I'd like
> some opinions on whether it's possible/probable.
These seem like fairly indirect ways of limiting resource usage. Why
not instead set a direct limit on the amount of runtime allowed?
Postgres doesn't use the ITIMER_VIRTUAL (CPU time) timer, so about all
you'd need issetitimer(ITIMER_VIRTUAL, &itimer, NULL);
to a suitable limit before starting query execution, and cancel it again
at successful query end. Set the SIGVTALRM signal handler to
QueryCancelHandler (same as SIGINT), and voila. A direct solution in
about ten lines of code ...
regards, tom lane