X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 503ED9FA5D8 for ; Sun, 28 May 2006 18:56:42 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 76349-03 for ; Sun, 28 May 2006 18:56:31 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id 1A6059F9F3D for ; Sun, 28 May 2006 18:56:31 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 9826831963; Sun, 28 May 2006 23:56:29 +0200 (MET DST) Date: Sun, 28 May 2006 23:56:27 +0200 From: Erwin Brandstetter User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) MIME-Version: 1.0 X-Newsgroups: comp.databases.postgresql,pgsql.performance Subject: Re: Query performance References: <1148294589.715695@proxy.dienste.wien.at> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: X-Complaints-To: abuse@chello.at Organization: chello.at Lines: 30 To: pgsql-performance@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/547 X-Sequence-Number: 19334 Antonio Batovanja wrote: > Laurenz Albe wrote: > >> Antonio Batovanja wrote: >>> I'm having trouble understanding, why a specific query on a small >>> database is taking so long... >>> >> Before I try to understand the execution plans: >> >> Have you run ANALYZE on the tables involved before you ran the query? > > Hi, > > Just to be on the safe side, I've run ANALYZE now. > Here are the query plans for the two queries: I suspect a misunderstanding here. What Laurenz probably meant is to run analyze on the involved _tables_ so the statistics data is refreshed. If the query planner runs with outdated statistics, queries may perform very poorly. Try vacuum full analyze yourdatabase To fully vacuum your database and analyze all tables. (vacuum full is extra, but can't hurt.) http://www.postgresql.org/docs/8.1/static/sql-vacuum.html http://www.postgresql.org/docs/8.1/static/sql-analyze.html Regards, Erwin