From: Craig James <craig_james@emolecules.com>
To: pgsql-admin@postgresql.org
Subject: Re: Pre-Allocate tablespace on disk
Date: Mon, 15 Nov 2010 13:49:27 -0800
Message-ID: <4CE1AAE7.1090406@emolecules.com> (raw)
In-Reply-To: <9CB65F11-6FA4-48D5-BCC5-B3F694659965@ruprecht.org>
References: <9CB65F11-6FA4-48D5-BCC5-B3F694659965@ruprecht.org>
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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: craig_james@emolecules.com
Subject: Re: Pre-Allocate tablespace on disk
In-Reply-To: <4CE1AAE7.1090406@emolecules.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox