Re: [SQL] limit 1 and functional indexes: SOLVED

2004-01-30 Thread Greg Stark
"Alexandra Birch" <[EMAIL PROTECTED]> writes: > It works perfectly - thanks a million! > Strangely the offset 0 does not seem to make any difference. > Gotta read up more about subqueries :) > > explain analyze > select code,order_date >from ( > select code, order_date >

Re: [SQL] limit 1 and functional indexes: SOLVED

2004-01-30 Thread Alexandra Birch
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Sent: viernes, 30 de enero de 2004 7:08 > > Yeah, the problem with functional indexes is that the optimizer doesn't have > any clue how the records are distributed since it only has statistics for > columns, not your expression. Notice it's est

Re: [SQL] limit 1 and functional indexes

2004-01-29 Thread Greg Stark
Bruno Wolff III <[EMAIL PROTECTED]> writes: > >QUERY PLAN > > > > Sort (cost=11824.16..11831.5

Re: [SQL] limit 1 and functional indexes

2004-01-29 Thread Bruno Wolff III
On Thu, Jan 29, 2004 at 16:02:06 +0100, Alexandra Birch <[EMAIL PROTECTED]> wrote: > > Here is the output of EXPLAIN ANALYZE first with limit 1 then without: The time estimate for the limit 1 case is way off. I can't tell if that is a bug or not having detailed enough statistics. Hopefully som

Re: [SQL] limit 1 and functional indexes

2004-01-29 Thread Alexandra Birch
> > > > Postgres choses the wrong index when I add limit 1 to the query. > > This should not affect the index chosen. > > I don't know the complete answer to your question, but since no one else > has commented I will answer what I can. Thanks - your reply is apreciated :) > It IS reasobable for

Re: [SQL] limit 1 and functional indexes

2004-01-29 Thread Bruno Wolff III
On Wed, Jan 28, 2004 at 12:23:38 +0100, Alexandra Birch <[EMAIL PROTECTED]> wrote: > Hi, > > Postgres choses the wrong index when I add limit 1 to the query. > This should not affect the index chosen. I don't know the complete answer to your question, but since no one else has commented I will

[SQL] limit 1 and functional indexes

2004-01-28 Thread Alexandra Birch
Hi, Postgres choses the wrong index when I add limit 1 to the query. This should not affect the index chosen. I read that functional indexes are sometimes not chosen correctly by optimizer. Is there anything I can do to always use the functional index in the following queries? Query with limi