X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id D4939D1B8E6 for ; Fri, 29 Aug 2003 07:04:12 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 96039-07 for ; Fri, 29 Aug 2003 04:03:43 -0300 (ADT) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by svr1.postgresql.org (Postfix) with ESMTP id F2BC6D1B8CC for ; Fri, 29 Aug 2003 04:03:39 -0300 (ADT) Received: from klaster.net (core-1.citynet.pl [80.48.135.69]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 393772B3A4; Fri, 29 Aug 2003 09:03:28 +0200 (CEST) Message-ID: <3F4EFAB6.7030104@klaster.net> Date: Fri, 29 Aug 2003 09:03:18 +0200 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; pl-PL; rv:1.5a) Gecko/20030718 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: Alexander Priem Cc: pgsql-performance@postgresql.org Subject: Re: Indexing question References: <012f01c36dfa$0f4a8760$b696a8c0@APR> In-Reply-To: <012f01c36dfa$0f4a8760$b696a8c0@APR> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/472 X-Sequence-Number: 3288 > Hi all, > > I have some tables (which can get pretty large) in which I want to > record 'current' data as well as 'historical' data. This table has > fields 'deleted' and 'deleteddate' (among other fields, of course). The > field 'deleted' is false be default. Every record that I want to delete > gets the value true for 'deleted' and 'deleteddate' is set to the date > of deletion. > > Since these tables are used a lot by queries that only use 'current' > data, I have created a view with a where clause 'Where not deleted'. > Also, I have indexed field 'deleted'. I think the best choice for your case is using conditional indexes. It should be much better than indexing 'deleted' field. I don't know on which exactly fields you have to create this index - you have to check it by yourself - what do you have in "where" clause? Example: create index some_index on your_table(id_field) where not deleted; Regards, Tomasz Myrta