Re: Force a merge join? - Mailing list pgsql-general

From Tom Lane
Subject Re: Force a merge join?
Date
Msg-id 23478.1021753149@sss.pgh.pa.us
Whole thread Raw
In response to Re: Force a merge join?  (Doug Fields <dfields-pg-general@pexicom.com>)
Responses Re: Force a merge join?
List pgsql-general
Doug Fields <dfields-pg-general@pexicom.com> writes:
> In fact, yes it does. How do I know? Very simple: I did a SELECT * INTO ...
> to copy my real table to a testing table so I could refactor it. Then I did
> the usual EXPLAIN ANALYZE queries, and it was using merge joins. Then, I
> did an "ANALYZE" (which is like VACUUM ANALYZE without the slow VACUUM) and
> voila - nested loops and half second queries turning into five minute
> nightmares. Then enable_nestloop would fix the problem again after that.

Could we see the usual details here?  Before and after EXPLAIN ANALYZE,
and the schemas and pg_stats rows for the tables involved.

BTW, you don't really have to reload a table to get back to the
"unanalyzed" condition for testing purposes.  You can just manually
delete the rows from pg_statistic:

delete from pg_statistic where
  starelid = (select oid from pg_class where relname = 'mytable');

            regards, tom lane

pgsql-general by date:

Previous
From: Tim Hart
Date:
Subject: Fwd: Ordering of data on calls to user defined aggregate.
Next
From: Tom Lane
Date:
Subject: Re: Ordering of data on calls to user defined aggregate.