Re: Improving Inner Join Performance

From: Frank Wiles <frank(at)wiles(dot)org>
To: "Andy" <frum(at)ar-sd(dot)net>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Improving Inner Join Performance
Date: 2006-01-05 19:20:06
Message-ID: 20060105132006.19c7cd31.frank@wiles.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Thu, 5 Jan 2006 17:16:47 +0200
"Andy" <frum(at)ar-sd(dot)net> wrote:

> Hi to all,
>
> I have the following query:
>
> SELECT count(*) FROM orders o
> INNER JOIN report r ON r.id_order=o.id
> WHERE o.id_status>3

> How can I improve this query's performace?? The ideea is to count all
> the values that I have in the database for the following conditions.
> If the users puts in some other search fields on the where then the
> query runs faster but in this format sometimes it takes a lot lot of
> time(sometimes even 2,3 seconds).
>
> Can this be tuned somehow???

Do you have an index on report.id_order ? Try creating an index for
it if not and run a vacuum analyze on the table to see if it gets
rid of the sequence scan in the plan.

---------------------------------
Frank Wiles <frank(at)wiles(dot)org>
http://www.wiles.org
---------------------------------

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Qingqing Zhou 2006-01-05 23:12:13 Re: Help in avoiding a query 'Warm-Up' period/shared buffer cache
Previous Message Markus Schaber 2006-01-05 16:44:05 Re: What's the best hardver for PostgreSQL 8.1?