Query Performance When Dropping Multiple Columns
Clash 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;
postgresql query-performance alter-table
add a comment |Â
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;
postgresql query-performance alter-table
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
add a comment |Â
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;
postgresql query-performance alter-table
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;
postgresql query-performance alter-table
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
add a comment |Â
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
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
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.
answered Aug 28 at 8:16
Jimmy Stenke
61335
61335
add a comment |Â
add a comment |Â
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
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
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
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
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
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