X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id CD503D1B55B for ; Fri, 14 Nov 2003 15:10:39 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 01129-03 for ; Fri, 14 Nov 2003 11:10:12 -0400 (AST) Received: from mystic.root.hu (mystic.root.hu [62.68.166.4]) by svr1.postgresql.org (Postfix) with ESMTP id 8203FD1B50B for ; Fri, 14 Nov 2003 11:10:07 -0400 (AST) Received: from [213.163.10.103] (helo=fejleszt4) by mystic.root.hu with asmtp (Exim 3.36 #1 (Debian)) id 1AKfaC-0007Qh-00 (authenticated sender: fac545198474dd6187837a07256e3b3f) for ; Fri, 14 Nov 2003 16:10:00 +0100 Message-ID: <01a601c3aac1$281e72c0$0403a8c0@fejleszt4> From: "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" To: Subject: constant vs function param differs in performance Date: Fri, 14 Nov 2003 16:08:27 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Authenticated-Sender: fac545198474dd6187837a07256e3b3f X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200311/110 X-Sequence-Number: 4670 Dear Gurus, I have two SQL function that produce different times and I can't understand why. Here is the basic difference between them: CREATE FUNCTION test_const_1234 () RETURNS int4 AS ' SELECT ... 1234 ... 1234 .... 1234 ... ' LANGUAGE 'SQL'; CREATE FUNCTION test_param (int4) RETURNS int4 AS ' SELECT ... $1 .... $1 .... $1 ... ' LANGUAGE 'SQL'; Some sample times for different data: test_const_1234() 450 msec test_param(1234) 2700-4000 msec (probably disk cache) test_const_5678() 13500 msec test_param(5678) 14500 msec Is there a sane explanation? a solution? I can send more info if you wish. TIA, G. ------------------------------- cut here -------------------------------