Rate-limiting query execution in a batch process












1















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.










share|improve this question
















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
















1















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.










share|improve this question
















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














1












1








1








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.










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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



















  • 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










1 Answer
1






active

oldest

votes


















0














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;





share|improve this answer

























    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    0














    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;





    share|improve this answer






























      0














      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;





      share|improve this answer




























        0












        0








        0







        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;





        share|improve this answer















        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;






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited May 18 '17 at 5:53

























        answered May 18 '17 at 5:45









        Evan CarrollEvan Carroll

        31.3k865209




        31.3k865209






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Liste der Baudenkmale in Friedland (Mecklenburg)

            Single-Malt-Whisky

            Czorneboh