Re: Ad Hoc Indexes

From: "Stephen Denne" <Stephen(dot)Denne(at)datamail(dot)co(dot)nz>
To: "Justin" <justin(at)emproshunts(dot)com>
Cc: <tgl(at)sss(dot)pgh(dot)pa(dot)us>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Ad Hoc Indexes
Date: 2008-02-19 01:01:07
Message-ID: F0238EBA67824444BC1CB4700960CB4804B0BC05@dmpeints002.isotach.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Justin wrote:
> Then why are the estimates so far off?

Perhaps a really high correlation between those records where coitem_status = 'O' and those records in your date range. The planner estimates 1 row when restricting by both restrictions, whereas there where 458. The 1 row was probably a result of a small % for status='O' multiplied by a small % for the date range.

> If estimates where correct would it improve the performance that much.

Possibly, but a better performance gain might be obtained by rewriting the query, changing the case expression to something along the lines of:

coalesce((
select wrkcnt_code || ' Operation Completed :' || cast(wooper_seqnumber as text)
from wooper inner join wrkcnt on wrkcnt_id = wooper_wrkcnt_id
where wooper_rncomplete = true and wooper_wo_id = coitem_order_id
order by wooper_seqnumber desc limit 1
),'No Operation Completed') as LastFinshedOp

regards,
Stephen Denne.

Disclaimer:
At the Datamail Group we value team commitment, respect, achievement, customer focus, and courage. This email with any attachments is confidential and may be subject to legal privilege. If it is not intended for you please advise by reply immediately, destroy it and do not copy, disclose or use it in any way.

__________________________________________________________________
This email has been scanned by the DMZGlobal Business Quality
Electronic Messaging Suite.
Please see http://www.dmzglobal.com/services/bqem.htm for details.
__________________________________________________________________

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2008-02-19 01:16:38 Re: Severe regression in autoconf 2.61
Previous Message Tom Lane 2008-02-18 23:31:35 Severe regression in autoconf 2.61