Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Simply Too Slow Find and Replace

by mandog (Curate)
on Jun 03, 2002 at 12:46 UTC ( [id://171210]=note: print w/replies, xml ) Need Help??


in reply to Simply Too Slow Find and Replace

thor has given you the best advice in this thread. You should look again here

If I understand your problem correctly, you should also seriously consider whether or not Perl is the tool. SQL is designed precisely for this job. Even with 250 substituions to make, you can meet your million record per hour goal with the right indexes and halfway modern hardware.

Also for the non Perl people that follow you this:
UPDATE my_table SET name='Admin' WHERE name='Administrator';
..is easier to follow than the Perl.

Another (maybe better?) more perlish way to take advantage of the indexes in your database would be to use DBI to create a cached SQL statement with placeholders. You could loop through, stuffing items from your list of substitutions into the placeholders..



email: mandog

Replies are listed 'Best First'.
Re: Re: Simply Too Slow Find and Replace
by Sifmole (Chaplain) on Jun 03, 2002 at 12:53 UTC
    And that will only work where the entire column "name" is "Admin". Whereas the user has described a case where the entire "name" contains "Admin" -- and your solution would do absolutely nothing to fix the data.
      But if he can use sql, surely you would agree that it would be much faster.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://171210]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (7)
As of 2024-04-18 03:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found