Received: from kosh.pollcities.com (kosh.pollcities.com [202.186.13.219]) by hub.org (8.10.1/8.10.1) with ESMTP id e779I6G23322 for ; Mon, 7 Aug 2000 05:18:06 -0400 (EDT) Received: (from angch@localhost) by kosh.pollcities.com (8.9.3/8.9.3) id RAA31912 for pgsql-sql@postgresql.org; Mon, 7 Aug 2000 17:11:11 +0800 Date: Mon, 7 Aug 2000 17:11:10 +0800 From: Ang Chin Han To: pgsql-sql@postgresql.org Subject: Functions too slow, even with iscachable? Message-ID: <20000807171110.A31838@pintoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0.1i X-Archive-Number: 200008/48 I have a query which runs fast: SELECT passwd FROM ticket WHERE name = ticket2name('test-006kdt') AND survey_id = ticket2survey_id('test-006kdt'); But slows down to a crawl when I wrapped it in a function: CREATE FUNCTION ticket2passwd(text) RETURNS text AS 'SELECT passwd FROM ticket WHERE name = ticket2name($1) AND ticket2survey_id($1)' LANGUAGE 'sql' WITH (iscachable); which should be a shortform for the first query: SELECT ticket2passwd('test-006kdt'); Any ideas? Thanks in advance. ticket2name and ticket2survey_id are both iscachable. BTW, pg_dump doesn't seem to preserve the iscachable attribute. Bug?