On Tue, May 4, 2010 at 5:17 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> FWIW, that's not the case, anymore than it is for blocks in shared
> buffer cache for regular rels. smgrextend() results in an observable
> extension of the file EOF immediately, whether or not you can see
> up-to-date data for those pages.
>
> Now people have often complained about the extra I/O involved in that,
> and it'd be nice to have a solution, but it's not clear to me that
> fixing it would be harder for temprels than regular rels.
For systems that have it and filesystems that optimize it I think
posix_fallocate() handles this case. We can extend files without
actually doing any i/o but we get the guarantee from the filesystem
that it has the space available and writing to those blocks won't fail
due to lack of space. Only meta-data i/o is triggered allocating the
blocks and marking them as virtually filled with nulls and it's not
synced unless there's an fsync so there's no extra physical i/o.
This should be the case for ext4 but I'm not sure what other
filesystems implement this.
--
greg