Re: postgres 9 query performance
От | yazan suleiman |
---|---|
Тема | Re: postgres 9 query performance |
Дата | |
Msg-id | AANLkTim+7MDYM_dF4Ki2WfwU68XUMV1XVoAFNMTnULYr@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: postgres 9 query performance (Andres Freund <andres@anarazel.de>) |
Список | pgsql-performance |
OK, that did it. Time is now 315 ms. I am so exited working with postgres. I really apologize for the format, my first time posting on the list. That does not justify it though. Really thanks.
On Fri, Jan 28, 2011 at 1:19 PM, Andres Freund <andres@anarazel.de> wrote:
On Friday, January 28, 2011 06:30:19 PM yazan suleiman wrote:First:
> I am evaluating postgres 9 to migrate away from Oracle. The following
> query runs too slow, also please find the explain plan:
explain analyze
SELECT DISTINCTEVENT.IDFROM
,ORIGIN.ID AS ORIGINID
,EVENT.PREFERRED_ORIGIN_ID AS PREFERRED_ORIGIN
,EVENT.CONTRIBUTOR
,ORIGIN.TIME
,ORIGIN.LATITUDE
,ORIGIN.LONGITUDE
,ORIGIN.DEPTH
,ORIGIN.EVTYPE
,ORIGIN.CATALOG
,ORIGIN.AUTHOR OAUTHOR
,ORIGIN.CONTRIBUTOR OCONTRIBUTOR
,MAGNITUDE.ID AS MAGID
,MAGNITUDE.MAGNITUDE
,MAGNITUDE.TYPE AS MAGTYPEevent.eventI am honestly stumped if anybody can figure something sensible out of the
left join event.origin on event.id = origin.eventid
left join event.magnitude on origin.id = event.magnitude.origin_id
WHERE
EXISTS(
select origin_id
from event.magnitude
where magnitude.magnitude >= 7.2 and origin.id = origin_id
)
order by
ORIGIN.TIME desc
,MAGNITUDE.MAGNITUDE desc
,EVENT.ID
,EVENT.PREFERRED_ORIGIN_ID
,ORIGIN.ID
original formatting of the query...
What happens if you change theleft join event.origin on event.id = origin.eventidintojoin event.origin on event.id = origin.eventid?
The EXISTS() requires that origin is not null anyway. (Not sure why the
planner doesn't recognize that though).
Andres
В списке pgsql-performance по дате отправления: