Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U0ugy-0003IP-Rc for pgsql-general@arkaria.postgresql.org; Thu, 31 Jan 2013 14:00:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U0ugx-0003LC-RB for pgsql-general@arkaria.postgresql.org; Thu, 31 Jan 2013 14:00:39 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U0ugv-0003Jt-Qt for pgsql-general@postgresql.org; Thu, 31 Jan 2013 14:00:37 +0000 Received: from smtp10.smtpout.orange.fr ([80.12.242.132] helo=smtp.smtpout.orange.fr) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U0ugt-00041j-Dw for pgsql-general@postgresql.org; Thu, 31 Jan 2013 14:00:37 +0000 Received: from [192.168.1.10] ([193.251.178.45]) by mwinf5d45 with ME id ue0Z1k00e0z9ZVd03e0ZBs; Thu, 31 Jan 2013 15:00:34 +0100 Subject: Re: Optimizing query? From: Vincent Veyron To: Pavel Stehule Cc: pgsql-general@postgresql.org In-Reply-To: References: <1359616050.2444.3.camel@asus-1001PX.home> <1359626588.2444.18.camel@asus-1001PX.home> Content-Type: text/plain; charset="ISO-8859-15" Date: Thu, 31 Jan 2013 15:00:30 +0100 Message-ID: <1359640830.2444.29.camel@asus-1001PX.home> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org Le jeudi 31 janvier 2013 à 11:06 +0100, Pavel Stehule a écrit : > 2013/1/31 Vincent Veyron : > > > > Suppose I have a query of the form > > > > SELECT my_function(column_1), column_2 > > FROM my_table > > GROUP BY my_function(column_1) > > ORDER BY my_function(column_1); > > > > where my_function is a user defined function. > > > > How many times is the function computed? > > if function is stable or immutable, then once per row > In this post (watch for line-wrap) : http://www.postgresql.org/message-id/CAFj8pRAdYL1-hCxH +QSZQKHt9YnoaOiGkfX4cNc9mzUTimcs1w@mail.gmail.com you wrote that it is usually better not to mark SQL functions (as opposed to plpgsql functions). So should I mark SQL functions stable/immutable if I use them in a query like the one above, or is it unnecessary? -- Salutations, Vincent Veyron http://marica.fr/site/demonstration Logiciel de gestion des contentieux juridiques et des sinistres d'assurance -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general