in reply to Query takes 895ms in TOAD but 42s in DBI

Try profiling it, for example with Devel::NYTProf, and see where the time is spent, maybe that will give you some answers.
  • Comment on Re: Query takes 895ms in TOAD but 42s in DBI