X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9BFBCD1B562 for ; Wed, 21 Apr 2004 04:46:57 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 38316-05 for ; Wed, 21 Apr 2004 04:46:57 -0300 (ADT) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 9E145D1B507 for ; Wed, 21 Apr 2004 04:46:54 -0300 (ADT) Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id i3L7klWL048815; Wed, 21 Apr 2004 15:46:47 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Message-ID: <40862857.4030008@familyhealth.com.au> Date: Wed, 21 Apr 2004 15:52:55 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Edoardo Ceccarelli Cc: pgsql-performance@postgresql.org Subject: Re: slow seqscan References: <40862003.2090201@axa.it> In-Reply-To: <40862003.2090201@axa.it> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=HTML_MESSAGE, HTML_TAG_BALANCE_TABLE X-Spam-Level: X-Archive-Number: 200404/333 X-Sequence-Number: 6633 Hi Edoardo, > The table is well indexed so that most of the queries are executed with > index scan but since there is a big text field in the table (360chars) > some search operation (with certain filters) ends up with seq scans. Please paste the exact SELECT query that uses a seqscan, plus the EXPLAIN ANALYZE of the SELECT, and the psql output of \d . > This table is not written during normal operation: twice per week there > is a batch program that insert about 35.000 records and updates another > 40.000. After such an update, you need to run VACUUM ANALYZE
; Run it before the update as well, if it doesn't take that long. > last friday morning, after that batch has been executed, the database > started responding really slowly to queries (expecially seq scans), > after a "vacuum full analize" things did get something better. > Yesterday the same: before the batch everything was perfect, after every > query was really slow, I've vacuum it again and now is ok. > Since now the db was working fine, it's 4 month's old with two updates > per week and I vacuum about once per month. You need to vacuum analyze (NOT full) once and HOUR, not once a month. Add this command to your crontab to run once an hour and verify that it's working: vacuumdb -a -z -q Otherwise, install the auto vacuum utility found in contrib/pg_autovacuum in the postgres source. Set this up. It will monitor postgres and run vacuums and analyzes when necessary. You can then remove your cron job. > I am using version 7.3 do I need to upgrade to 7.4? also, I was thinking > about setting this table in a kind of "read-only" mode to improve > performance, is this possible? There's no read only mode to improve performance. Upgrading to 7.4 will more than likely improve the performance of your database in general. Be careful to read the upgrade notes because there were a few incompatibilities. Chris