Re: any hope for my big query?

From: Jim Nasby <jimn(at)enterprisedb(dot)com>
To: Ben <bench(at)silentmedia(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: any hope for my big query?
Date: 2006-10-06 04:02:57
Message-ID: AB73891F-7475-4ADE-9D90-04E7CC1545EF@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Oct 4, 2006, at 4:40 PM, Ben wrote:
> I'm surprised (though probably just because I'm ignorant) that it
> would have so much sequential scanning in there. For instance,
> because n is going to have at most a couple dozen rows, it seems
> that instead of scanning all of public.track, it should be able to
> convert my "t.length between a and b" clause to some between
> statements or'd together. Or at least, it would be nice if the
> planner could do that.

That would require the planner having that knowledge at plan-time,
which it can't without actually querying the database. One thing that
might work wonders is performing the n query ahead of time and then
sticking it in an array... that might speed things up.

Worst case, you could run the n query, and then run the rest of the
query for each row of n you get back.

Better yet... send us a patch that allows the planner to look into
what a subselect will return to us. ;)
--
Jim Nasby jim(at)nasby(dot)net
EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)

--
Jim Nasby jimn(at)enterprisedb(dot)com
EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Carlo Stonebanks 2006-10-06 16:44:29 Re: Performance Optimization for Dummies 2 - the SQL
Previous Message Jim Nasby 2006-10-06 03:52:47 Re: Unsubscribe