If Not True Then False

PostgreSQL Sleep Function pg_sleep – Postgres Delay Execution - Comment Page: 1

One day, I was looking for PostgreSQL database function, which could delay the execution of queries. At first I thought that I will do one myself, because I do not remember ever seen this kind function. But then I found pg_sleep Postgres function which directly delay execution of the server process. pg_sleep makes the current session’s process sleep until seconds seconds have elapsed....
Categories:

5 Comments

Leave a Comment

Your email address will not be published. Required fields are marked *

Input your comment.
help

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Input your name.

Deepak

Can we create some number of slow queries?
say create 100 slow queries (200 seconds) from one sql statement only? kind of for loop?

reply Reply
JR

Hi Deepak,

So do you mean in general, do loop, which loops thru 100 queries?

reply Reply
Deepak

yes, actually, I found a way to do it from shell script.
A script calls one query and I call that script n number of times in bash for loop.

but just wanted to know if bash for loop like concept is there in postgres or not to make it simpler.

reply Reply
JR

First, nice to hear that you get this solved, with bash script.

Yes, it’s possible do functions on postgresql db and do very complicated structures if you want to.

Which is better way on your case (pgsql functions or bash script), depends totally on your SQL queries, do you need this functionality on some application or is this just onetime process / cron process, and what you want to do with returned data?

reply Reply
Deepak

I just want to simulate the slow queries to block the psql connections and to check how our monitoring system responds.

I used the same query which you gave above.

reply Reply