Hi all,
I have a table with a little over 200,000 columns in it that I need
to update using a regular expression. I admit that though I am not a
beginner and postgres, I am also far from an expert. :p
I tried to create an Index that would optimize the UPDATE but I may
have made an error in how I built it. Here is the table structure, the
index I tried to create and an 'EXPLAIN ANALYZE' of the UPDATE (though I
am still just now learning how to use 'EXPLAIN').
tle-bu=> \d file_info_3
Table "public.file_info_3"
Column | Type | Modifiers
-----------------+----------------------+-----------------------------------------
file_group_name | text | not null
file_group_uid | bigint | not null
file_mod_time | bigint | not null
file_name | text | not null
file_parent_dir | text | not null
file_perm | text | not null
file_size | bigint | not null
file_type | character varying(2) | not null default
'f'::character varying
file_user_name | text | not null
file_user_uid | bigint | not null
file_backup | boolean | not null default true
file_display | boolean | not null default false
file_restore | boolean | not null default false
Indexes:
"file_info_3_display_idx" btree (file_type, file_parent_dir, file_name)
Here is the EXPLAIN:
tle-bu=> EXPLAIN ANALYZE UPDATE file_info_3 SET file_backup='f' WHERE
file_parent_dir~'^/home' OR (file_parent_dir='/' AND file_name='home');
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------
Seq Scan on file_info_3 (cost=0.00..7770.00 rows=1006 width=206)
(actual time=1050.813..5648.462 rows=67835 loops=1)
Filter: ((file_parent_dir ~ '^/home'::text) OR ((file_parent_dir =
'/'::text) AND (file_name = 'home'::text)))
Total runtime: 68498.898 ms
(3 rows)
I thought that it would have used the index because 'file_parent_dir'
and 'file_name' are in the index but is I am reading the "EXPLAIN"
output right it isn't but is instead doing a sequencial scan. If that is
the case, how would I best built the index? Should I have just used the
'file_parent_dir' and 'file_name'?
Thanks all!!
Madison
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Madison Kelly (Digimer)
TLE-BU, The Linux Experience; Back Up
http://tle-bu.thelinuxexperience.com
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-