in reply to script optimization
Your script isn't doing much, so I'd guess you have a lot of data or a slow machine to run it on.
Please provide: