Re: Query is 800 times slower when running in function! - Mailing list pgsql-performance

From Tom Lane
Subject Re: Query is 800 times slower when running in function!
Date
Msg-id 6648.1133413080@sss.pgh.pa.us
Whole thread Raw
In response to Query is 800 times slower when running in function!  (Ralph Mason <ralph.mason@telogis.com>)
List pgsql-performance
Ralph Mason <ralph.mason@telogis.com> writes:
> I have a simple query that is running inside a plpgsql function.

> SELECT INTO _point_id id FROM ot2.point WHERE unit_id = _unit_id AND
> time > _last_status ORDER BY time LIMIT 1;

It would probably help significantly to make that be
"ORDER BY unit_id, time".  This'd eliminate the need for the separate
sort step and encourage the planner to use the index, even when it does
not know whether the "time > x" condition is selective or not.

            regards, tom lane

pgsql-performance by date:

Previous
From: Ron
Date:
Subject: Re: RES: pg_dump slow
Next
From: "Tatsumi Abe"
Date:
Subject: About the relation between fragmentation of file and VACUUM