Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 540D71337B7E for ; Mon, 15 Nov 2010 17:56:26 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 36609-08 for ; Mon, 15 Nov 2010 21:56:20 +0000 (UTC) X-Greylist: delayed 00:06:47.617256 by SQLgrey-1.7.6 Received: from mail-vw0-f46.google.com (mail-vw0-f46.google.com [209.85.212.46]) by mail.postgresql.org (Postfix) with ESMTP id E4AEE1337B2F for ; Mon, 15 Nov 2010 17:56:18 -0400 (AST) Received: by vws13 with SMTP id 13so1983508vws.19 for ; Mon, 15 Nov 2010 13:56:18 -0800 (PST) Received: by 10.220.178.195 with SMTP id bn3mr1551915vcb.121.1289857770250; Mon, 15 Nov 2010 13:49:30 -0800 (PST) Received: from Craig-Jamess-MacBook-Pro.local (wsip-70-167-124-126.sd.sd.cox.net [70.167.124.126]) by mx.google.com with ESMTPS id v20sm187306vbw.9.2010.11.15.13.49.28 (version=SSLv3 cipher=RC4-MD5); Mon, 15 Nov 2010 13:49:29 -0800 (PST) Message-ID: <4CE1AAE7.1090406@emolecules.com> Date: Mon, 15 Nov 2010 13:49:27 -0800 From: Craig James User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.12) Gecko/20101027 Thunderbird/3.1.6 MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: Re: Pre-Allocate tablespace on disk References: <9CB65F11-6FA4-48D5-BCC5-B3F694659965@ruprecht.org> In-Reply-To: <9CB65F11-6FA4-48D5-BCC5-B3F694659965@ruprecht.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201011/128 X-Sequence-Number: 36094 On 11/15/10 11:42 AM, Chris Ruprecht wrote: > I was wondering if there is a way to pre-allocate tablespace on disk before > adding data and indexes. > My understanding is: > PG writes data into files sequentially. If more space is needed, disk space > is requested from the OS and if there is space, the OS will give PG a file > system block and PG will write data/indexes until that block is full and so on. > Other database that I have worked with before and that I'm still working with, > allow you to pre-allocate disk space so you get huge chunks of contiguous > space at one, which has major impacts on database performance. This shouldn't really be a performance issue on modern Unix-type systems. Most file systems have fairly smart block-allocation algorithms that tend to allocate large blocks of contiguous space to files even when lots of processes are asking for little chunks in interleaved requests. It doesn't just allocate a block to the next guy who happens to ask. It's a lot smarter than that. In most cases, you'll barely be able to tell the difference between a file that was allocated all at once and one that was allocated on an as-needed basis. The only time you get bad fragmentation is when your disk gets nearly full, which takes away the file system's ability to be clever. If you really want to preallocate a file, build a separate partition on your disk and only put one database (or even just one table) on that file system.