Re: Pre-Allocate tablespace on disk - Mailing list pgsql-admin

From Craig James
Subject Re: Pre-Allocate tablespace on disk
Date
Msg-id 4CE1AAE7.1090406@emolecules.com
Whole thread Raw
In response to Pre-Allocate tablespace on disk  (Chris Ruprecht <chris@ruprecht.org>)
Responses ignoring data type
List 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-allocationalgorithms that tend to allocate large blocks of contiguous space to files even when lots of processes
areasking 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
allocatedall at once and one that was allocated on an as-needed basis.  The only time you get bad fragmentation is when
yourdisk 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
justone table) on that file system. 

pgsql-admin by date:

Previous
From: Samuel Stearns
Date:
Subject: Re: GUI ERD/ERM tools?
Next
From: "Olli Aro"
Date:
Subject: could not map view of backend variables: error code 6