Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id C5B4E3E3C9B for ; Sun, 4 Dec 2011 08:54:42 -0400 (AST) Received: from mahout.postgresql.org ([98.129.198.123]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RXBaa-0004kx-F1 for pgsql-bugs@postgresql.org; Sun, 04 Dec 2011 12:54:42 +0000 Received: from [204.145.120.229] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RXBaM-0004hO-68 for pgsql-bugs@postgresql.org; Sun, 04 Dec 2011 12:54:27 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1RXBaL-0000K2-U2 for pgsql-bugs@postgresql.org; Sun, 04 Dec 2011 12:54:25 +0000 Date: Sun, 04 Dec 2011 12:54:25 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #6325: Useless Index updates To: pgsql-bugs@postgresql.org From: dmigowski@ikoffice.de X-Pg-Spam-Score: -3.1 (---) X-Archive-Number: 201112/31 X-Sequence-Number: 31842 The following bug has been logged on the website: Bug reference: 6325 Logged by: Daniel Migowski Email address: dmigowski@ikoffice.de PostgreSQL version: 8.3.16 Operating system: Linux Description: = It seems that an update to a row in a table always removes the element from an index and adds it again. Wouldn't it be faster to check for equality of the index parameters in the OLD and NEW record first? = I have this problem with an functional index using a relative expensive index function, and noticed that the index function is always called even if the parameter to the index function has not changed. Wouldn't it be better to validate that the input to the index functions has not changed, instead of calling the index function over and over again? Especially since the index functions seems to be called with the new and the old value anyway. I can understand that this might be a precaution in the case that the index function isn't stable (is it even possible to use such a function for an index?), but in the stable case comparing the input parameters allows for much much faster table updates.