Rate-limiting query execution in a batch process
I have a set of queries in my queries.sql file which I am feeding to psql for execution. But I don't want them to run instantly one after the other: I would like to set some sort of delay - I was looking at watch and query buffer but I am not so sure how to proceed. I would prefer not to write PG_SLEEP after each of my queries.
postgresql psql sleep
bumped to the homepage by Community♦ 20 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I have a set of queries in my queries.sql file which I am feeding to psql for execution. But I don't want them to run instantly one after the other: I would like to set some sort of delay - I was looking at watch and query buffer but I am not so sure how to proceed. I would prefer not to write PG_SLEEP after each of my queries.
postgresql psql sleep
bumped to the homepage by Community♦ 20 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
why do you want a delay after the queries? how do you want the delay to look so as not to sleep?
– Evan Carroll
Mar 4 '17 at 23:41
1
Write a Python or Perl script with your list of queries and have it loop over them, sleeping after each execution.
– Craig Ringer
Mar 5 '17 at 11:18
add a comment |
I have a set of queries in my queries.sql file which I am feeding to psql for execution. But I don't want them to run instantly one after the other: I would like to set some sort of delay - I was looking at watch and query buffer but I am not so sure how to proceed. I would prefer not to write PG_SLEEP after each of my queries.
postgresql psql sleep
I have a set of queries in my queries.sql file which I am feeding to psql for execution. But I don't want them to run instantly one after the other: I would like to set some sort of delay - I was looking at watch and query buffer but I am not so sure how to proceed. I would prefer not to write PG_SLEEP after each of my queries.
postgresql psql sleep
postgresql psql sleep
edited May 18 '17 at 6:14
Evan Carroll
31.3k865209
31.3k865209
asked Mar 4 '17 at 22:33
audlift-bitaudlift-bit
636
636
bumped to the homepage by Community♦ 20 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 20 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
why do you want a delay after the queries? how do you want the delay to look so as not to sleep?
– Evan Carroll
Mar 4 '17 at 23:41
1
Write a Python or Perl script with your list of queries and have it loop over them, sleeping after each execution.
– Craig Ringer
Mar 5 '17 at 11:18
add a comment |
why do you want a delay after the queries? how do you want the delay to look so as not to sleep?
– Evan Carroll
Mar 4 '17 at 23:41
1
Write a Python or Perl script with your list of queries and have it loop over them, sleeping after each execution.
– Craig Ringer
Mar 5 '17 at 11:18
why do you want a delay after the queries? how do you want the delay to look so as not to sleep?
– Evan Carroll
Mar 4 '17 at 23:41
why do you want a delay after the queries? how do you want the delay to look so as not to sleep?
– Evan Carroll
Mar 4 '17 at 23:41
1
1
Write a Python or Perl script with your list of queries and have it loop over them, sleeping after each execution.
– Craig Ringer
Mar 5 '17 at 11:18
Write a Python or Perl script with your list of queries and have it loop over them, sleeping after each execution.
– Craig Ringer
Mar 5 '17 at 11:18
add a comment |
1 Answer
1
active
oldest
votes
watch
executes the query buffer (one statement). It doesn't loop through different statements.
set title "EVAN SAYS HAI"
SELECT 'HELLO WORLD' AS "Evan Greets the Plebs";
watch
Now move that window over to your fifth monitor and when the boss comes by pretend like you're waiting for it to change.
If you want to put a delay in between query executions, make a spool as @Craig Ringer said in the comments
Write a Python or Perl script with your list of queries and have it loop over them, sleeping after each execution. – Craig Ringer Mar 5 at 11:18
You can do it one line or whatever too..
echo -e "SELECT 1;nSELECT 2;nSELECT 3;" |
perl -pe'$|=1; sleep 1;' |
psql -d foo;
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "182"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f166218%2frate-limiting-query-execution-in-a-batch-process%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
watch
executes the query buffer (one statement). It doesn't loop through different statements.
set title "EVAN SAYS HAI"
SELECT 'HELLO WORLD' AS "Evan Greets the Plebs";
watch
Now move that window over to your fifth monitor and when the boss comes by pretend like you're waiting for it to change.
If you want to put a delay in between query executions, make a spool as @Craig Ringer said in the comments
Write a Python or Perl script with your list of queries and have it loop over them, sleeping after each execution. – Craig Ringer Mar 5 at 11:18
You can do it one line or whatever too..
echo -e "SELECT 1;nSELECT 2;nSELECT 3;" |
perl -pe'$|=1; sleep 1;' |
psql -d foo;
add a comment |
watch
executes the query buffer (one statement). It doesn't loop through different statements.
set title "EVAN SAYS HAI"
SELECT 'HELLO WORLD' AS "Evan Greets the Plebs";
watch
Now move that window over to your fifth monitor and when the boss comes by pretend like you're waiting for it to change.
If you want to put a delay in between query executions, make a spool as @Craig Ringer said in the comments
Write a Python or Perl script with your list of queries and have it loop over them, sleeping after each execution. – Craig Ringer Mar 5 at 11:18
You can do it one line or whatever too..
echo -e "SELECT 1;nSELECT 2;nSELECT 3;" |
perl -pe'$|=1; sleep 1;' |
psql -d foo;
add a comment |
watch
executes the query buffer (one statement). It doesn't loop through different statements.
set title "EVAN SAYS HAI"
SELECT 'HELLO WORLD' AS "Evan Greets the Plebs";
watch
Now move that window over to your fifth monitor and when the boss comes by pretend like you're waiting for it to change.
If you want to put a delay in between query executions, make a spool as @Craig Ringer said in the comments
Write a Python or Perl script with your list of queries and have it loop over them, sleeping after each execution. – Craig Ringer Mar 5 at 11:18
You can do it one line or whatever too..
echo -e "SELECT 1;nSELECT 2;nSELECT 3;" |
perl -pe'$|=1; sleep 1;' |
psql -d foo;
watch
executes the query buffer (one statement). It doesn't loop through different statements.
set title "EVAN SAYS HAI"
SELECT 'HELLO WORLD' AS "Evan Greets the Plebs";
watch
Now move that window over to your fifth monitor and when the boss comes by pretend like you're waiting for it to change.
If you want to put a delay in between query executions, make a spool as @Craig Ringer said in the comments
Write a Python or Perl script with your list of queries and have it loop over them, sleeping after each execution. – Craig Ringer Mar 5 at 11:18
You can do it one line or whatever too..
echo -e "SELECT 1;nSELECT 2;nSELECT 3;" |
perl -pe'$|=1; sleep 1;' |
psql -d foo;
edited May 18 '17 at 5:53
answered May 18 '17 at 5:45
Evan CarrollEvan Carroll
31.3k865209
31.3k865209
add a comment |
add a comment |
Thanks for contributing an answer to Database Administrators Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f166218%2frate-limiting-query-execution-in-a-batch-process%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
why do you want a delay after the queries? how do you want the delay to look so as not to sleep?
– Evan Carroll
Mar 4 '17 at 23:41
1
Write a Python or Perl script with your list of queries and have it loop over them, sleeping after each execution.
– Craig Ringer
Mar 5 '17 at 11:18