Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TZ8Av-0004og-5o for pgsql-bugs@postgresql.org; Thu, 15 Nov 2012 22:44:45 +0000 Received: from mail-da0-f46.google.com ([209.85.210.46]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TZ8As-0004VK-U0 for pgsql-bugs@postgresql.org; Thu, 15 Nov 2012 22:44:44 +0000 Received: by mail-da0-f46.google.com with SMTP id n41so862793dak.19 for ; Thu, 15 Nov 2012 14:44:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:x-mailer:content-transfer-encoding :x-gm-message-state; bh=3r1kKp8Wye5zaE7tAnmcC155T6uSrMGtMH9HGFHp/HY=; b=DiQKJ/EtEZALHg0bP3vd0MmQDsElo9OJj8mVhxvR+tCaXxvliOUGKp0QU3OahV7oOa hWn6nQWLjycf+eHrFFhj3Zoftq8fi8129DpzCYv+w6+KRMhKbrGvfqXh6RsXvfqMSKmn aIFVb/3dMuTpWjO2vWtLj15zaoTVvw6MSv9dOJ4/Mlc1O/N02U1gWuoBOy/PeVZYcW4N JyYPXAO4flTPhmrdZo8y7zRa+GzX/1kN0+0B72mVtRnVwkj71TI5eDCXzit6SXrefMpY B7TQzrzNYBDKxEctGaflMzYo6L9C33i43M9yo3PpPUyQjmyuPuHa3lhkx6wDrefv96ve wtAg== Received: by 10.68.235.2 with SMTP id ui2mr3349347pbc.163.1353019481086; Thu, 15 Nov 2012 14:44:41 -0800 (PST) Received: from ?IPv6:::1? ([2600:3c01::f03c:91ff:fe93:2ae4]) by mx.google.com with ESMTPS id hs2sm77488pbc.22.2012.11.15.14.44.39 (version=SSLv3 cipher=OTHER); Thu, 15 Nov 2012 14:44:40 -0800 (PST) Subject: Re: BUG #7651: Superfluous calls to functions used for indexing From: Jeff Davis To: m-pg@8d.no Cc: pgsql-bugs@postgresql.org In-Reply-To: References: Content-Type: text/plain; charset="ISO-8859-1" Date: Thu, 15 Nov 2012 14:44:38 -0800 Message-ID: <1353019478.14335.23.camel@sussancws0025> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQmYgmzJoZa3oPnJtwab8yP6SXEltV27y/XbrEoiE4MnpkL1UsBD7GxaUNVgOGmSMuqOdR1z X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201211/81 X-Sequence-Number: 34639 On Sun, 2012-11-11 at 15:45 +0000, m-pg@8d.no wrote: > Bug: When making an index over a function, then selecting a result that does > not contain the function call (but orders on it), Superfluous function calls > are made. This possibly because the plan creates a projection containing the > function value. It's possible that the function call may be unnecessary, but that is more of a performance enhancement, not a bug. Also, the example function has side effects. If you declare functions with side effects to be IMMUTABLE, you can get all kinds of problems. You should certainly not rely on an IMMUTABLE function to be called a specific number of times. Regards, Jeff Davis