X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3AD76528C9 for ; Tue, 24 May 2005 23:39:28 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 53879-08 for ; Wed, 25 May 2005 02:39:19 +0000 (GMT) Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu [128.255.17.47]) by svr1.postgresql.org (Postfix) with ESMTP id C6E48528CC for ; Tue, 24 May 2005 23:39:14 -0300 (ADT) Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu [128.255.17.51]) by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id j4P2dH2D023270; (envelope-from ) Tue, 24 May 2005 21:39:17 -0500 (CDT) Received: from [192.168.1.11] (12-215-118-172.client.mchsi.com [12.215.118.172]) (authenticated user=jfmeinel) by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id j4P2dFhn002032 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); (envelope-from ) Tue, 24 May 2005 21:39:16 -0500 (CDT) Message-ID: <4293E553.6070400@arbash-meinel.com> Date: Tue, 24 May 2005 21:39:15 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: SpaceBallOne Cc: pgsql-performance@postgresql.org Subject: Re: Can anyone explain this: duplicate dbs. References: In-Reply-To: X-Enigmail-Version: 0.91.0.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigED7884077674065F15DD39B9" X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/380 X-Sequence-Number: 12544 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigED7884077674065F15DD39B9 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit SpaceBallOne wrote: > Wondering if someone could explain a pecularity for me: > > We have a database which takes 1000ms to perform a certain query on. > > If I pg_dump that database then create a new database (e.g. "tempdb") > and upload the dump file (thus making a duplicate) then the same query > only takes 190ms !! > Vacuum, vacuum analyse, and vacuum full analyse does not seem to have > an impact on these times. > > Can anyone explain why this may be occurring and how I might be able > to keep the original database running at the same speed as "tempdb"? > > Thanks in advance, > > Dave. What version of postgres? There are a few possibilities. If you are having a lot of updates to the table, you can get index bloat. And vacuum doesn't fix indexes. You have to "REINDEX" to do that. Though REINDEX has the same lock that VACUUM FULL has, so you need to be a little careful with it. Probably better is to do CLUSTER, as it does a REINDEX and a sort, so your table ends up nicer when you are done. Also, older versions of postgres had a worse time with index bloat. One thing that caused a lot of problem is a table that you insert into over time, so that all the values are incrementing. If you are deleting older entries, that area won't be re-used because they fall at the back end. I believe newer versions have been fixed. By the way, I think doing: CREATE DATABASE tempdb WITH TEMPLATE = originaldb; Is a much faster way of doing dump and load. I *think* it would recreate indexes, etc. If it just does a copy it may not show the dump/restore improvement. John =:-> --------------enigED7884077674065F15DD39B9 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (Cygwin) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCk+VTJdeBCYSNAAMRAiw1AKDI0lX0lcNbKRhISBsKsuX44PlMKACgw7HL GZx7dCOTb0xRh+lzhx5b0ds= =WYPz -----END PGP SIGNATURE----- --------------enigED7884077674065F15DD39B9--