You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Hugh Ross <hh...@gmail.com> on 2008/01/31 20:38:42 UTC
How does RowHandler help performance?
I've looked at the docs (In Action book, Developer Guide 2.0, and wiki), and
somehow I've missed this.
I have seen threads in the user-java Mail Archive saying that it can, but
I'm not clear on how.
Thanks...
P.S. Actually, I believe only the Dev Guide mentions RowHandler
specifically, and there only briefly.
Re: How does RowHandler help performance?
Posted by Hugh Ross <hh...@gmail.com>.
Thanks. I see now the key difference. The queryWithRowHandler methods do
not return anything! I was thinking the List was built anyway.
So, assuming I don't build my own List in the RowHandler, it saves memory.
Got it. Definitely should be considered for larger result sets that only
need to be processed once.
Hugh
On 1/31/08, Clinton Begin <cl...@gmail.com> wrote:
>
> Row handlers are not necessarily faster... they just use less memory.
> Thus, if you count the time to resize arrays, grow the heap and possibly
> garbage collect, they will be faster for indirect reasons.
>
>
>
> Internally, by default, iBATIS uses a RowHandler that simply gathers up
> all of the result objects and adds them to a list to be returned (it
> actually uses it even for a single queryForObject as well).
>
>
>
> So if you write your own RowHandler implementation, it's possible to
> process row-by-row...
>
>
>
> That's a pretty rare thing to do in most transactional and/or web based
> systems. It's more for batch processing of lots of rows.
>
>
>
> One example of where I used a row handler was for an integration task
> between a MySQL database and a SQL Server... ETL of sorts. The RowHandler
> would read from MySQL, transform the record, perform some simple
> calculations, and batch inserts into SQL Server. On my test machine running
> both databases (3GHz 2GB RAM 2x10k HDD), I was able to achieve throughput of
> 15,000 records per second on millions of rows.
>
>
>
> So they CAN be fast. They aren't just fast by default, and they're not
> for every situation.
>
>
>
> Clinton
>
>
>
> *From:* Hugh Ross [mailto:hh4ross@gmail.com]
> *Sent:* January-31-08 12:39 PM
> *To:* user-java@ibatis.apache.org
> *Subject:* How does RowHandler help performance?
>
>
>
>
>
> I've looked at the docs (In Action book, Developer Guide 2.0, and wiki),
> and somehow I've missed this.
>
>
>
> I have seen threads in the user-java Mail Archive saying that it can, but
> I'm not clear on how.
>
>
>
> Thanks...
>
>
>
> P.S. Actually, I believe only the Dev Guide mentions RowHandler
> specifically, and there only briefly.
>
RE: How does RowHandler help performance?
Posted by Clinton Begin <cl...@gmail.com>.
Row handlers are not necessarily faster... they just use less memory. Thus,
if you count the time to resize arrays, grow the heap and possibly garbage
collect, they will be faster for indirect reasons.
Internally, by default, iBATIS uses a RowHandler that simply gathers up all
of the result objects and adds them to a list to be returned (it actually
uses it even for a single queryForObject as well).
So if you write your own RowHandler implementation, it's possible to process
row-by-row...
That's a pretty rare thing to do in most transactional and/or web based
systems. It's more for batch processing of lots of rows.
One example of where I used a row handler was for an integration task
between a MySQL database and a SQL Server... ETL of sorts. The RowHandler
would read from MySQL, transform the record, perform some simple
calculations, and batch inserts into SQL Server. On my test machine running
both databases (3GHz 2GB RAM 2x10k HDD), I was able to achieve throughput of
15,000 records per second on millions of rows.
So they CAN be fast. They aren't just fast by default, and they're not for
every situation.
Clinton
From: Hugh Ross [mailto:hh4ross@gmail.com]
Sent: January-31-08 12:39 PM
To: user-java@ibatis.apache.org
Subject: How does RowHandler help performance?
I've looked at the docs (In Action book, Developer Guide 2.0, and wiki), and
somehow I've missed this.
I have seen threads in the user-java Mail Archive saying that it can, but
I'm not clear on how.
Thanks...
P.S. Actually, I believe only the Dev Guide mentions RowHandler
specifically, and there only briefly.