From: Madison Kelly <linux@alteeve.com>
To: Philip Hallstrom <postgresql@philip.pjkh.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Very long time to execute and Update, suggestions?
Date: Thu, 31 Mar 2005 14:51:51 -0500
Message-ID: <424C54D7.5020906@alteeve.com> (raw)
In-Reply-To: <20050331111709.P55747@wolf.pjkh.com>
References: <424C49A1.1090003@alteeve.com>
<20050331111709.P55747@wolf.pjkh.com>
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~'^/<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
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: linux@alteeve.com, postgresql@philip.pjkh.com
Subject: Re: Very long time to execute and Update, suggestions?
In-Reply-To: <424C54D7.5020906@alteeve.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox