pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: pgsql-performance@postgresql.org
To: pgsql-hackers@postgresql.org
Cc: Michael Clemmons <glassresistor@gmail.com>
Cc: Hannu Krosing <hannu@2ndquadrant.com>
Cc: Scott Marlowe <scott.marlowe@gmail.com>
Subject: Faster CREATE DATABASE by delaying fsync (was 8.4.1 ubuntu karmic slow createdb)
Date: Mon, 28 Dec 2009 23:54:51 +0100
Message-ID: <200912282354.51892.andres@anarazel.de> (raw)
In-Reply-To: <200912122138.42404.andres@anarazel.de>
References: <4427a97a0912101235x3ade510blcc00d5ce9883c6b6@mail.gmail.com>
	<4427a97a0912121236g4c06c562u221d638810ed2b6e@mail.gmail.com>
	<200912122138.42404.andres@anarazel.de>

On Saturday 12 December 2009 21:38:41 Andres Freund wrote:
> On Saturday 12 December 2009 21:36:27 Michael Clemmons wrote:
> > If ppl think its worth it I'll create a ticket
> Thanks, no need. I will post a patch tomorrow or so.
Well. It was a long day...

Anyway.
In this patch I delay the fsync done in copy_file and simply do a second pass 
over the directory in copy_dir and fsync everything in that pass.
Including the directory - which was not done before and actually might be 
necessary in some cases.
I added a posix_fadvise(..., FADV_DONTNEED) to make it more likely that the 
copied file reaches storage before the fsync. Without the speed benefits were 
quite a bit smaller and essentially random (which seems sensible).

This speeds up CREATE DATABASE from ~9 seconds to something around 0.8s on my 
laptop.  Still slower than with fsync off (~0.25) but quite a worthy 
improvement.

The benefits are obviously bigger if the template database includes anything 
added.


Andres



view thread (70+ messages)  latest in thread

Message-ID: <200912282354.51892.andres@anarazel.de>
Permalink:  ../200912282354.51892.andres@anarazel.de/
Also on:    postgresql.org/message-id/200912282354.51892.andres@anarazel.de

 · 

reply

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-hackers@postgresql.org
  Cc: andres@anarazel.de, pgsql-performance@postgresql.org, glassresistor@gmail.com, hannu@2ndquadrant.com, scott.marlowe@gmail.com
  Subject: Re: Faster CREATE DATABASE by delaying fsync (was 8.4.1 ubuntu karmic slow createdb)
  In-Reply-To: <200912282354.51892.andres@anarazel.de>

* 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