X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4D0535360C for ; Thu, 31 Mar 2005 20:52:06 +0100 (BST) 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 52666-09 for ; Thu, 31 Mar 2005 19:51:56 +0000 (GMT) Received: from srv1.alteeve.com (unknown [209.167.86.38]) by svr1.postgresql.org (Postfix) with ESMTP id 141BC534F6 for ; Thu, 31 Mar 2005 20:51:55 +0100 (BST) Received: from [192.168.1.99] (nabiki.thelinuxexperience.com [209.167.86.34]) by srv1.alteeve.com (8.12.10/8.12.10) with ESMTP id j2VKB5sm024625; Thu, 31 Mar 2005 15:11:05 -0500 Message-ID: <424C54D7.5020906@alteeve.com> Date: Thu, 31 Mar 2005 14:51:51 -0500 From: Madison Kelly User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.6) Gecko/20050323 Fedora/1.7.6-1.3.2 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Philip Hallstrom Cc: pgsql-performance@postgresql.org Subject: Re: Very long time to execute and Update, suggestions? References: <424C49A1.1090003@alteeve.com> <20050331111709.P55747@wolf.pjkh.com> In-Reply-To: <20050331111709.P55747@wolf.pjkh.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200503/688 X-Sequence-Number: 11393 Philip Hallstrom wrote: > I'm not sure about this which is why I'm replying off list, but your > index is on file_type, file_parent_dir, and file_name and you're query > is on file_parent_dir and file_name. > > I seem to remember reading that that the index will only get used if the > columns in the where clause "match up" "in order". > > That is um... if you have an index on columns a and b and a where clause > of "b = 1" it woin't use the index since the index "looks like" > > a, b > a, b > a, b > etc... > > Does that make any sense? Not sure if that's right or not, but easy > enough to remove the "file_type" from your index and try it. > > post back to the list if that's it. > > -philip Thanks for the reply! I have played around a little more and have created a few different test Indexes and it looks like it is the regex that is causing it to do the sequential scan. If I remove the regex and create a 'file_parent_dir', 'file_name' index it will use it. If I create an Index just for 'file_parent_dir' and change my UPDATE to just look for the regex '... WHERE file_parent_dir~'^/'...' it will still do the sequential scan anyway. So I need to either find an Index that will work with regexes or re-write my code to update each subdirectory separately and use simpler UPDATE statement for each. Thanks again! Madison PS - I cc'ed the list to follow up on what I found out so far. (Hi list!) -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Madison Kelly (Digimer) TLE-BU, The Linux Experience; Back Up http://tle-bu.thelinuxexperience.com -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-