Re: Need suggestion on how best to update 3 million rows

Поиск
Список
Период
Сортировка
От Ow Mun Heng
Тема Re: Need suggestion on how best to update 3 million rows
Дата
Msg-id 1189061278.17792.63.camel@neuromancer.home.net
обсуждение исходный текст
Ответ на Need suggestion on how best to update 3 million rows  (Ow Mun Heng <Ow.Mun.Heng@wdc.com>)
Ответы Re: Need suggestion on how best to update 3 million rows  (Alban Hertroys <alban@magproductions.nl>)
Список pgsql-general
On Thu, 2007-09-06 at 14:13 +0800, Ow Mun Heng wrote:
> I have a table in PG, Pulled from SQL Server using Perl DBI (w/o using
> chopblanks) and have ended up with a column where the "space" is being
> interpreted as a value.
>
> eg:
>
> "ABC " when it should be "ABC"
>
> this is being defined  as varchar(4)
>
> I've already pull the relevent columns with
>
> create foo as select unique_id, rtrim(number) from org_column
>
> I've tried to do the update using
>
> update org_column set number = foo.number where foo.unique_id =
> org_column=unique_id.
>
> The update is taking a few hours and still hasn't ended.
>
> I've killed it already and rolled back the changes.
>
> what's the easiest way to update these fields?
>
>
> Thanks..


Bad Form.. I know.. replying to my own post.. but..

I found 2 new ways to do this.

option 1
-------

create table foo as select unique_id, rtrim(number) as number from foo;
alter table add primary key...
create index...
drop org_table
alter table rename...
All this is ~10min


option 2
========
This I saw in the mysql archives (in my laptop).. when I say this I
went.. WTF? This is possible?? Dang IT!

update a set number=replace(number,'ABC ', 'ABC') where reptest like '%
ABC%';

of course this will need to parse it through like a couple of times,
unless I use some regex magic etc..

but anyway.. problem solved and using chopblanks => 1 now..

В списке pgsql-general по дате отправления:

Предыдущее
От: Ow Mun Heng
Дата:
Сообщение: Need suggestion on how best to update 3 million rows
Следующее
От: Alban Hertroys
Дата:
Сообщение: Re: Need suggestion on how best to update 3 million rows