X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1C83FD7E91 for ; Sat, 27 Aug 2005 03:20:17 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 44540-03 for ; Sat, 27 Aug 2005 06:20:13 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.197.194]) by svr1.postgresql.org (Postfix) with SMTP id 5B517D7E62 for ; Sat, 27 Aug 2005 03:20:11 -0300 (ADT) Received: (qmail 28325 invoked by uid 500); 27 Aug 2005 06:19:49 -0000 Date: Sat, 27 Aug 2005 01:19:49 -0500 From: Bruno Wolff III To: "Lenard, Rohan (Rohan)" Cc: pgsql-performance@postgresql.org Subject: Re: Need indexes on empty tables for good performance ? Message-ID: <20050827061949.GB27248@wolff.to> Mail-Followup-To: Bruno Wolff III , "Lenard, Rohan (Rohan)" , pgsql-performance@postgresql.org References: <2773CAC687FD5F4689F526998C7E4E5F43F392@au3010avexu1.global.avaya.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2773CAC687FD5F4689F526998C7E4E5F43F392@au3010avexu1.global.avaya.com> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200508/472 X-Sequence-Number: 14219 On Tue, Aug 23, 2005 at 13:41:32 +1000, "Lenard, Rohan (Rohan)" wrote: > I've read that indexes aren't used for COUNT(*) and I've noticed (7.3.x) > with EXPLAIN that indexes never seem to be used on empty tables - is > there any reason to have indexes on empty tables, or will postgresql > never use them. count will use indexes if appropiate. The counts themselves are NOT in the indexes, so counts of significant fractions of a table (in particular of the whole table) won't benefit from indexes. You aren't going to get query speed ups by putting indexes on empty tables. However, they may be required if you have unique or primary keys declared in the table. You may want them to enforce some kinds of constraints.