X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 30B888B9E7A for ; Wed, 9 Feb 2005 17:15:30 +0000 (GMT) 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 20410-05 for ; Wed, 9 Feb 2005 17:15:06 +0000 (GMT) Received: from koolancexeon.g2switchworks.com (mail.g2switchworks.com [63.87.162.25]) by svr1.postgresql.org (Postfix) with ESMTP id 91ECC8B9FAD for ; Wed, 9 Feb 2005 17:15:05 +0000 (GMT) Received: mail.g2switchworks.com 10.10.1.8 from 10.10.1.37 10.10.1.37 via HTTP with MS-WebStorage 6.5.6944 Received: from state.g2switchworks.com by mail.g2switchworks.com; 09 Feb 2005 11:15:03 -0600 Subject: Re: too slow From: Scott Marlowe To: Marek Lewczuk Cc: Shashi Gireddy , pgsql-admin@postgresql.org In-Reply-To: <420A41F1.5070007@lewczuk.com> References: <6B18E29D62790047B57F5B602D4B096EA1CE1A@hermes.cs.ua.edu> <420A41F1.5070007@lewczuk.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Message-Id: <1107969303.11967.6.camel@state.g2switchworks.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Wed, 09 Feb 2005 11:15:03 -0600 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200502/73 X-Sequence-Number: 16241 On Wed, 2005-02-09 at 11:01, Marek Lewczuk wrote: > Shashi Gireddy napisa=C5=82(a): > > I recently migrated from MySql, The database size in mysql was 1.4GB (I= t is a static database). It generated a dump file (.sql) of size 8GB), It t= ook 2days to import the whole thing into postgres. After all the response f= rom postgres is a disaster. It took 40sec's to run a select count(logrecno)= from sf10001; which generated a value 197569. And It took for ever time to= display the table. How to optimize the database so that I can expect faste= r access to data. > > =20 > > each table has 70 colsX197569 rows (static data), like that I have 40 t= ables, Everything static. > > =20 > > system configuration: p4 2.8ghz 512mb ram os: xp postgres version: 8.0 > First of all you should make VACUUM FULL ANALYZE for the all tables=20 > (http://www.postgresql.org/docs/8.0/interactive/sql-vacuum.html) - this=20 > should solve the problem. However you should also think about changing=20 > table structure, because PostgreSQL needs different indexes than MySQL.=20 > A few months ago I had the same problem - but after vacuuming, making=20 > proper indexes everything is working like a charm. Believe me that you=20 > can achieve the same speed - it is only a matter of good db structure=20 > and environment settings=20 > (http://www.postgresql.org/docs/8.0/interactive/runtime.html). This user may also benefit from better normalization, as i remember him having lots of fields in each table. Note that since PostgreSQL has to hit the tables AFTER hitting the indexes due to MVCC, having wide, denormalized tables with indexes is a sub-optimal solution, while narrower tables are often much faster. It sounded to me like what the OP was doing was more fittingly described as "batch processing" and might well be better handled without a database at all.