From: | Justin <justin(at)emproshunts(dot)com> |
---|---|
To: | Stephen Denne <Stephen(dot)Denne(at)datamail(dot)co(dot)nz> |
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:30:41 |
Message-ID: | 47BA3141.2020500@emproshunts.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
yes that improved the select statement allot from 18 to 20 to 6
seconds 3 fold improvement with no indexes. thanks
Now i tested your new and improved select statement with the indexes its
query time was taking from 90 to 140 milliseconds compared to the
original select statement of 94 to 120 milliseconds. I tested both
select statements 5 times to get an average and they both hover around
110 to 120
I attached the results from the explain that used the indexes and one
with no index
although in both case with and with out indexes the estimate still
failed to return the correct number by allot.
Stephen Denne wrote:
> 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.
> __________________________________________________________________
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>
Attachment | Content-Type | Size |
---|---|---|
newimprovequerynoindexes.txt | text/plain | 3.2 KB |
newimproved querywithindexes.txt | text/plain | 3.8 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2008-02-19 01:36:20 | Re: Severe regression in autoconf 2.61 |
Previous Message | Bruce Momjian | 2008-02-19 01:16:38 | Re: Severe regression in autoconf 2.61 |