[Dbix-class] how do resultsets actually work under the hood?

Iain C Docherty dbix-class at iain-docherty.com
Tue May 28 21:37:41 GMT 2013


I was in conversation with a Java programmer today about the design of a
database system, in a nutshell he was saying that in Java he would create a
'collection' of all rows in a table and then iterate over the collection of
objects. If it was too big he would 'split' the query by searching for all
records starting with 'a', then 'b' etc.

I was appalled that this would eat up memory, and starting going on about
DBIC and how in Perl I would create a resultset then iterate over it using
'next'.

I soon realized that I didn't have much idea how this 'just worked' under
the surface (in DBI I presume?) without using large amounts of memory to
hold every row from the table.

I have done some digging since, I have looked at the DBI code, but frankly
I got rather lost.

So, can anyone give a concise description on how this works, in particular.

Where (if anywhere) does it store a record of every row in a resultset so
that I can just call 'next' and quickly get the next row.

Or does it do this by making a request to the database for every row? Isn't
this slow?

Thank you.
Iain.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20130528/925=
eb98c/attachment.htm


More information about the DBIx-Class mailing list