Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 42CFC1AEBA96 for ; Tue, 24 Jan 2012 17:28:34 -0400 (AST) Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Rpnuq-0004wo-IH for pgsql-performance@postgresql.org; Tue, 24 Jan 2012 21:28:34 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id q0OLSHIR007728; Tue, 24 Jan 2012 16:28:17 -0500 (EST) To: Tony Capobianco cc: Pavel Stehule , pgsql-performance@postgresql.org Subject: Re: Cursor fetch performance issue In-reply-to: <1327438657.1968.15.camel@tony1.localdomain> References: <1327437700.1968.10.camel@tony1.localdomain> <1327438657.1968.15.camel@tony1.localdomain> Comments: In-reply-to Tony Capobianco message dated "Tue, 24 Jan 2012 15:57:37 -0500" Date: Tue, 24 Jan 2012 16:28:17 -0500 Message-ID: <7727.1327440497@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201201/67 X-Sequence-Number: 46079 Tony Capobianco 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@hotmail.com' > 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