From: | BladeOfLight16 <bladeoflight16(at)gmail(dot)com> |
---|---|
To: | Jesse Long <jpl(at)unknown(dot)za(dot)net> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Incorrect index being used |
Date: | 2013-10-11 23:45:40 |
Message-ID: | CA+=1U=U+jDm83azDBO1kyHT=SEVwr5h5j1WaiKXTY4CoepfXUg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, Oct 11, 2013 at 9:32 AM, Jesse Long <jpl(at)unknown(dot)za(dot)net> wrote:
> explain select * from archive_document_index where node_id = 29 and value
> = 'BSH70002152';
> QUERY PLAN
> ------------------------------**------------------------------**
> ------------------------------**------------------------------**--
> Index Scan using archive_document_index_node_**id_value_idx on
> archive_document_index (cost=0.57..36.13 rows=14 width=33)
> Index Cond: ((node_id = 29) AND ((value)::text = 'BSH70002152'::text))
> (2 rows)
>
I believe that this is what Tom is suggesting:
SELECT *
FROM ARCHIVE_DOCUMENT AS ad
WHERE ad.NODE_ID = 29
AND ad.ARCHIVE_DATE >= '2013-07-08 18:28:00'
AND EXISTS (SELECT *
FROM ARCHIVE_DOCUMENT_INDEX AS adi
WHERE adi.ARCHIVE_ID = ad.ID
AND adi.NODE_ID = ad.NODE_ID
AND (adi.VALUE = 'BSH70002152' OR adi.VALUE = 'TC212592')
)
ORDER BY ad.ARCHIVE_DATE DESC
LIMIT 10;
Forgive my changing of the aliases. I found names like r0 difficult to
interpret easily.
This is a much simpler query since it only requires one subselect, and I
believe Tom is suggesting that this query may be able to make use of the
index or at least find some more efficient plan. How does this perform?
From | Date | Subject | |
---|---|---|---|
Next Message | mbetter95 | 2013-10-12 07:08:34 | Re: postgres 9.0.4 configuration and performance issue |
Previous Message | Sergey Konoplev | 2013-10-11 23:03:48 | Re: postgres 9.0.4 configuration and performance issue |