Query Performance When Dropping Multiple Columns

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
1
down vote

favorite












In PostgreSQL, is there any performance gain when using a single ALTER TABLE statement to drop multiple columns, instead of using a separate statement to drop each column?



ALTER TABLE table DROP COLUMN col1, DROP COLUMN col2, DROP COLUMN 3;

// vs

ALTER TABLE table DROP COLUMN col1;
ALTER TABLE table DROP COLUMN col2;
ALTER TABLE table DROP COLUMN col3;






share|improve this question




















  • I put this question here because it is about query-performance, a topic covered by this site. If it belongs to SO please let me know.
    – Tamer Shlash
    Aug 28 at 7:26
















up vote
1
down vote

favorite












In PostgreSQL, is there any performance gain when using a single ALTER TABLE statement to drop multiple columns, instead of using a separate statement to drop each column?



ALTER TABLE table DROP COLUMN col1, DROP COLUMN col2, DROP COLUMN 3;

// vs

ALTER TABLE table DROP COLUMN col1;
ALTER TABLE table DROP COLUMN col2;
ALTER TABLE table DROP COLUMN col3;






share|improve this question




















  • I put this question here because it is about query-performance, a topic covered by this site. If it belongs to SO please let me know.
    – Tamer Shlash
    Aug 28 at 7:26












up vote
1
down vote

favorite









up vote
1
down vote

favorite











In PostgreSQL, is there any performance gain when using a single ALTER TABLE statement to drop multiple columns, instead of using a separate statement to drop each column?



ALTER TABLE table DROP COLUMN col1, DROP COLUMN col2, DROP COLUMN 3;

// vs

ALTER TABLE table DROP COLUMN col1;
ALTER TABLE table DROP COLUMN col2;
ALTER TABLE table DROP COLUMN col3;






share|improve this question












In PostgreSQL, is there any performance gain when using a single ALTER TABLE statement to drop multiple columns, instead of using a separate statement to drop each column?



ALTER TABLE table DROP COLUMN col1, DROP COLUMN col2, DROP COLUMN 3;

// vs

ALTER TABLE table DROP COLUMN col1;
ALTER TABLE table DROP COLUMN col2;
ALTER TABLE table DROP COLUMN col3;








share|improve this question











share|improve this question




share|improve this question










asked Aug 28 at 7:25









Tamer Shlash

1084




1084











  • I put this question here because it is about query-performance, a topic covered by this site. If it belongs to SO please let me know.
    – Tamer Shlash
    Aug 28 at 7:26
















  • I put this question here because it is about query-performance, a topic covered by this site. If it belongs to SO please let me know.
    – Tamer Shlash
    Aug 28 at 7:26















I put this question here because it is about query-performance, a topic covered by this site. If it belongs to SO please let me know.
– Tamer Shlash
Aug 28 at 7:26




I put this question here because it is about query-performance, a topic covered by this site. If it belongs to SO please let me know.
– Tamer Shlash
Aug 28 at 7:26










1 Answer
1






active

oldest

votes

















up vote
3
down vote



accepted










Yes, but it's too small to be noticed unless you plan to drop hundreds or even thousands of columns ;)



Each drop column is executed separately regardless if it's a separate statement, or part of a statement. The performance gain would be in the work postgres do before and after each statement, for instance taking a lock on the table, creating implicit transactions, and parsing the statement which it would only have to do once if all columns are dropped in one statement.






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',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    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%2f216020%2fquery-performance-when-dropping-multiple-columns%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    3
    down vote



    accepted










    Yes, but it's too small to be noticed unless you plan to drop hundreds or even thousands of columns ;)



    Each drop column is executed separately regardless if it's a separate statement, or part of a statement. The performance gain would be in the work postgres do before and after each statement, for instance taking a lock on the table, creating implicit transactions, and parsing the statement which it would only have to do once if all columns are dropped in one statement.






    share|improve this answer
























      up vote
      3
      down vote



      accepted










      Yes, but it's too small to be noticed unless you plan to drop hundreds or even thousands of columns ;)



      Each drop column is executed separately regardless if it's a separate statement, or part of a statement. The performance gain would be in the work postgres do before and after each statement, for instance taking a lock on the table, creating implicit transactions, and parsing the statement which it would only have to do once if all columns are dropped in one statement.






      share|improve this answer






















        up vote
        3
        down vote



        accepted







        up vote
        3
        down vote



        accepted






        Yes, but it's too small to be noticed unless you plan to drop hundreds or even thousands of columns ;)



        Each drop column is executed separately regardless if it's a separate statement, or part of a statement. The performance gain would be in the work postgres do before and after each statement, for instance taking a lock on the table, creating implicit transactions, and parsing the statement which it would only have to do once if all columns are dropped in one statement.






        share|improve this answer












        Yes, but it's too small to be noticed unless you plan to drop hundreds or even thousands of columns ;)



        Each drop column is executed separately regardless if it's a separate statement, or part of a statement. The performance gain would be in the work postgres do before and after each statement, for instance taking a lock on the table, creating implicit transactions, and parsing the statement which it would only have to do once if all columns are dropped in one statement.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Aug 28 at 8:16









        Jimmy Stenke

        61335




        61335



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f216020%2fquery-performance-when-dropping-multiple-columns%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            What does second last employer means? [closed]

            List of Gilmore Girls characters

            One-line joke