Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WuSDy-0002gU-38 for pgsql-bugs@arkaria.postgresql.org; Tue, 10 Jun 2014 20:00:50 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WuSDw-0000NA-K2 for pgsql-bugs@arkaria.postgresql.org; Tue, 10 Jun 2014 20:00:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1WuQw1-0003dQ-Pb for pgsql-bugs@postgresql.org; Tue, 10 Jun 2014 18:38:13 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WuQvr-0008Va-9S for pgsql-bugs@postgresql.org; Tue, 10 Jun 2014 18:38:12 +0000 MIME-Version: 1.0 Subject: BUG #10591: setting newly added columns to null is slow To: pgsql-bugs@postgresql.org From: eike@inter.net Date: Tue, 10 Jun 2014 18:37:19 +0000 Message-ID: <20140610183719.2589.93121@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.9 (-) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 10591 Logged by: Eike Dierks Email address: eike@inter.net PostgreSQL version: 9.2.1 Operating system: OSX 10.9, centos on virtuozzo linux-2.6.18-028stab Description: - given demo_table with some amount of data - add new_column (works instantely) - add a unique contraint on new_column - update demo_table set new_colum=null; (quite slow) -> takes a long time: seems to rewrite the whole table I guess that adding a new column does not yet reserve space for that new column on disk, but that the on-disk layout is only changed as soon as I do the update (aka making the column physically present on disk) I fully understand that this is a sensible tradeoff and that this is the intended behaviour. However from my uneducated guess (not tested) I believe that a vacuum full followed by the update would have been much faster. I somehow believe that my first sequence of commands did make the new_column virtual first and then physically for every row in turn, thereby taking a long time to complete. I'd like to suggest to add to the documentation (if it's not already in there) It should be stated that a vacuum full might speed up further access to a newly introduced column. But again I did not fully test that scenario, it's just my guess. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs