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.

--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

Reply via email to