Tony Capobianco <tcapobianco@xxxxxxxxxxxxxx> writes: > Running just the sql of the function returns only 10 rows: > pg=# SELECT m.memberid, m.websiteid, m.emailaddress, > pg-# m.firstname, m.lastname, m.regcomplete, m.emailok > pg-# FROM members m > pg-# WHERE m.emailaddress LIKE 'test.email@xxxxxxxxxxx' > pg-# AND m.changedate_id < 5868 ORDER BY m.emailaddress, m.websiteid; Based on that, I'd bet your problem is that the function is executing WHERE m.emailaddress LIKE $1 (for some spelling of $1) and you are therefore not getting the benefit of the index optimizations that can happen when LIKE's pattern is constant. Do you actually need LIKE rather than just "=" here? regards, tom lane -- Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance