Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 65C472E0069 for ; Thu, 17 Apr 2008 07:03:14 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 15355-07 for ; Thu, 17 Apr 2008 07:03:04 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.171]) by developer.postgresql.org (Postfix) with ESMTP id D7F2C2E006A for ; Thu, 17 Apr 2008 07:03:03 -0300 (ADT) Received: by ug-out-1314.google.com with SMTP id j3so1138531ugf.49 for ; Thu, 17 Apr 2008 03:03:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:organization:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; bh=gbI7v00n2spw+fA1BOoGfgGDxv9aKopHHUu6AuK2pVo=; b=Y1dQ74D6qRx9X+LZl+B/ZUsJqVS4GWbdq+qgPx+l0agYwikLXAUfA6gN9ZGscM+LsTNG50rCqSvV3vtXau7drNenVRaW2mERuNn8yd5wpdsJL8tdKI6r9BcOhyjMP6a5Tfncfq44WYBDtlLsVP+d8vZ8O5VxRS7mrHTwFE5n4R0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:organization:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=BoBoN3mF6M3wNt1vpw7rrDqaVjQF/H/Ikzk2BCWZv6POs8oynOO6XMkH1hHBFY1Cu5XrVv77gp3XCZaC6RyUUFZm+vLKJI9b8YfUckFJd7BxsG1G4WTfqdP4xK5nkyJDBFz5Xt2p6Ce9g2/FArEHSzAAF/VfPY01p1vQWeD9BAo= Received: by 10.67.121.2 with SMTP id y2mr8235010ugm.78.1208426581776; Thu, 17 Apr 2008 03:03:01 -0700 (PDT) Received: from ?192.168.0.199? ( [80.222.108.74]) by mx.google.com with ESMTPS id u6sm14581349uge.83.2008.04.17.03.02.59 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 17 Apr 2008 03:03:00 -0700 (PDT) Message-ID: <48072047.7030407@enterprisedb.com> Date: Thu, 17 Apr 2008 13:02:47 +0300 From: Heikki Linnakangas Organization: EnterpriseDB User-Agent: Mozilla-Thunderbird 2.0.0.9 (X11/20080110) MIME-Version: 1.0 To: Gunther Mayer CC: pgsql-performance@postgresql.org Subject: Re: Exact index overhead References: <48071807.8000409@gmail.com> In-Reply-To: <48071807.8000409@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/232 X-Sequence-Number: 29725 Gunther Mayer wrote: > You see, all updates change most of the data fields but never ever touch > the time field. Assuming correct and efficient behaviour of postgresql > it should then also never touch the time index and incur zero overhead > in its presence, but is this really the case? If it somehow does update > the index too even though the value hasn't changed by some weird > implementation detail I'd rather not have that index and live with slow > queries for the few times a day that reporting is run. Updates do generally modify the indexes as well. The way MVCC has been implemented in PostgreSQL, UPDATE is internally very much like DELETE+INSERT. A new row version is inserted, new index pointers are added for the new row version, and the old row version is marked as deleted. In version 8.3, however, the new HOT feature reduces the need for that. In a nutshell, if the new row version fits on the same page as the old one, no new index pointers need to be created. I would suggest just testing how much additional overhead the new index incurs. It might be less expensive than you think. You didn't mention how often the inserts happen, in other words, how fast you expect the table to grow. If the table is expected to grow orders of magnitude larger, you might want to partition the table by date. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com