Re: Same database, different query plans

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: WireSpot <wirespot(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Same database, different query plans
Date: 2005-08-18 14:05:14
Message-ID: 20050818140514.GA84091@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Aug 18, 2005 at 12:03:59PM +0300, WireSpot wrote:
> The actual SELECT results (ie. non EXPLAIN) are identical in both
> cases. The indexes and so on are identical. I've done a reindexing and
> vacuuming on both of them just to be sure.
>
> As you can see, there's quite a bit of a difference between 0.3 ms and
> 398 ms, and it shows. I haven't touched the query planning options.
> Why the different planning and what can I do to fix the misguided one?

Have you run ANALYZE or VACUUM ANALYZE in both databases to update
the planner's statistics? If you have and get the same results,
then it might be interesting to see the output of the following on
both systems:

SET enable_mergejoin TO off;
SET enable_nestloop TO on;
EXPLAIN ANALYZE SELECT ...

SET enable_mergejoin TO on;
SET enable_nestloop TO off;
EXPLAIN ANALYZE SELECT ...

--
Michael Fuhr

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Fuhr 2005-08-18 14:43:06 Re: How to determine table schema in trigger function
Previous Message Andrus 2005-08-18 14:02:58 How to determine table schema in trigger function