Re: [SQL] seemingly slow for-loop in plpgsql

2008-09-03 Thread Claus Guttesen
> Why in the world are you using a for-loop for this at all? It would be > tremendously faster as a single SQL command: > > update duplicates set hashcode = rtrim(hashcode, E'\n') where > length(hashcode) = 33; Thank you. I was "caught" in the plpgsql-lane. This is of course much simpler and muc

Re: [SQL] seemingly slow for-loop in plpgsql

2008-09-02 Thread Tom Lane
"Claus Guttesen" <[EMAIL PROTECTED]> writes: > create or replace function update_hashcode() returns setof duplicates as > $body$ > declare > d duplicates%rowtype; > h text; > begin > for d in select * from duplicates where length(hashcode) = 33 loop > h := rtrim(d.hashcode, E'\n'); >

[SQL] seemingly slow for-loop in plpgsql

2008-09-02 Thread Claus Guttesen
Hi. I have a table with a hashcode-field which is a md5-checksum of a file. I updated all null-entries using a rails-script by calling '/sbin/md5 -q' (on FreeBSD). When all null-entries were updated I found out that '\n' was added to the md5-checksum. :-) So I wanted to update the table using plp