Re: Fetch-on-demand iterators (was Re: [CDBI] Make CDBI go fast)
"Edward J. Sabol" <sabol-2oVx0MVsMgiP/[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.class-dbi |
|---|---|
| Message-ID | <[email protected]> |
Ed Sabol wrote: >> This sounds cool, but the change makes me nervous. Some DBMSs and/or DBDs >> (Sybase, for example) don't like unfinished statement handles hanging around. >> Could be problematic in a mod_perl environment? Michael Schwern replied: > Yes, this is a concern but its no worse a regular active statement handle. > It depends on how long your iterators live, you just now have to treat them > like you would statement handles. Further discussion and enhancements on > that can be found in the ticket notes on rt.cpan.org. > > One possibility is to move executing the statement handle into the iterator > so it doesn't even execute the query until you've asked for the first > object. This would make it safer to hand around iterator objects. > > I'm using this in a mod_perl environment with no problems yet. Yeah, but you're not using Sybase with mod_perl, and I am, so hence my nervousness. Although you're probably just using it as an extreme example, I don't really see much point in optimizing the specific case of CDBI->search(...)->first. If I had a search that might return a large number of rows, then I would specify a LIMIT in the SQL query using CDBI::Search::LIMITed: http://search.cpan.org/~tmtm/Class-DBI-Search-LIMITed/lib/Class/DBI/Search/LIMITed.pm Nice module. I have to hand it to Tony on his refactoring job in v3.0.x.