X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 764BDD1B503 for ; Sun, 28 Sep 2003 16:06:38 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 72214-10 for ; Sun, 28 Sep 2003 13:06:28 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id B65E7D1B51D for ; Sun, 28 Sep 2003 13:06:27 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id h8SG6M6c009399; Sun, 28 Sep 2003 12:06:22 -0400 (EDT) To: Josh Berkus Cc: "Richard Sydney-Smith" , pgsql-sql@postgresql.org Subject: Re: Mystery function error In-reply-to: <200309272229.50601.josh@agliodbs.com> References: <000c01c38572$73c03c50$251a32d2@athlon2000> <200309272229.50601.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Sat, 27 Sep 2003 22:29:50 -0700" Date: Sun, 28 Sep 2003 12:06:22 -0400 Message-ID: <9398.1064765182@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/359 X-Sequence-Number: 15337 Josh Berkus writes: > Also, this will run faster if you do it as a SQL function: > CREATE FUNCTION locate ( text, text ) RETURNS INT AS ' > SELECT POSITION($2, $1); > ' LANGUAGE SQL IMMUTABLE STRICT; This is definitely the solution I'd recommend for 7.4 (because 7.4 would inline the SQL function definition, resulting in zero runtime overhead). In 7.3 I suspect the plpgsql version might be a tad faster, or anyway comparable. Has anyone done any head-to-head performance comparisons on such simple functions? regards, tom lane