Re: Performance cost of a sort-merge join

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Yang Zhang <yanghatespam(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Performance cost of a sort-merge join
Date: 2010-02-22 17:10:13
Message-ID: 26794.1266858613@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Yang Zhang <yanghatespam(at)gmail(dot)com> writes:
> Hi, I have the given tables and query, but I'm confused why the cost
> of the query is so high.

The reason the estimated cost is so high is that the estimated number of
rows out of the join is enormous. It's going to take awhile. One
question worth asking is what you've got work_mem set to. Another
possible problem is that you're doing a lot of sorts/comparisons on
varchars, which could be pretty expensive if you're using a non-C locale.

> I've left it running over night. By
> comparison, a "select * from metarelcloud_transactionlog order by
> transactionid" takes on the order of seconds/minutes (at least in
> MySQL).

That's got approximately nothing to do with this query.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2010-02-22 17:15:17 Re: Un successful Restoration of DATA using WAL files
Previous Message Yang Zhang 2010-02-22 16:36:15 Performance cost of a sort-merge join