Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 42AFA64FDE5 for ; Tue, 14 Oct 2008 21:06:02 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 70144-05 for ; Tue, 14 Oct 2008 21:05:59 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from wa-out-1112.google.com (wa-out-1112.google.com [209.85.146.176]) by postgresql.org (Postfix) with ESMTP id 4982364FDDF for ; Tue, 14 Oct 2008 21:05:59 -0300 (ADT) Received: by wa-out-1112.google.com with SMTP id j4so1379765wah.19 for ; Tue, 14 Oct 2008 17:05:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=OBbMzu5Cab9waCXTFBcCF1oM2mmfu1/N91hJb+zAuTM=; b=qzwGKWsKSqYq71JTN3jqG5FyJdzGG7drsehNHizM/ZLs0s6v1C2Z3HChcjRqvPu8V9 H/tD/5Exl0qLDBjy9b7bFEpk67Skn4NJwgSWQTUv3katu1DKDgv29SYQj/8Ferx/HCxj iQS/Ho6BLH6MN9mbaMQv3KvQnOLGNxOK4XbBQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=VbUknv80HFW+Ca1pDlAlSQypqwRCFJFYHbPzwtc+rOpc3lxw2t90rvpRr5bHdA19dN ecFCeO02LeY+CvvJ6qlKpvivGZBF4JBejZtB3rqvUsfemKvm7dZJ4mBd2DWXM3qtRr3S cs9RrTXEh/b4+xKihyVL2t/dnhwtLmap0lCTY= Received: by 10.114.151.13 with SMTP id y13mr181780wad.134.1224029157610; Tue, 14 Oct 2008 17:05:57 -0700 (PDT) Received: by 10.114.39.11 with HTTP; Tue, 14 Oct 2008 17:05:57 -0700 (PDT) Message-ID: Date: Tue, 14 Oct 2008 18:05:57 -0600 From: "Scott Marlowe" To: "Rainer Mager" Subject: Re: speeding up table creation Cc: pgsql-performance@postgresql.org In-Reply-To: <000001c92e51$c42afcb0$4c80f610$@com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <000001c92e51$c42afcb0$4c80f610$@com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200810/76 X-Sequence-Number: 31657 On Tue, Oct 14, 2008 at 5:08 PM, Rainer Mager wrote: > I have an interesting performance improvement need. As part of the automatic > test suite we run in our development environment, we re-initialize our test > database a number of times in order to ensure it is clean before running a > test. We currently do this by dropping the public schema and then recreating > our tables (roughly 30 tables total). After that we do normal inserts, etc, > but never with very much data. My question is, what settings can we tweak to > improve performance is this scenario? Specifically, if there was a way to > tell Postgres to keep all operations in memory, that would probably be > ideal. I'm not sure we've identified the problem just yet. Do you have the autovacuum daemon enabled? Are your system catalogs bloated with dead tuples? Could you approach this by using a template database that was pre-setup for you and you could just "create database test with template test_template" or something like that? Also, if you're recreating a database you might need to analyze it first before you start firing queries. PostgreSQL buffers / caches what it can in shared_buffers. The OS also caches data in kernel cache. Having more memory makes it much faster. But if it writes, it needs to write. If the database server where this is happening doesn't have any important data in it, you might see a boost from disabling fsync, but keep in mind a server that loses power / crashes can corrupt all your databases in the db server. If you can fix the problem with any of those suggestions you might need to throw hardware at the problem.