Re: Pre-Allocate tablespace on disk

From: Craig James <craig_james(at)emolecules(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: Re: Pre-Allocate tablespace on disk
Date: 2010-11-15 21:49:27
Message-ID: 4CE1AAE7.1090406@emolecules.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

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.

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Olli Aro 2010-11-15 23:22:50 could not map view of backend variables: error code 6
Previous Message Samuel Stearns 2010-11-15 21:47:22 Re: GUI ERD/ERM tools?