java - Fast way to get results in hibernate? -


i have hibernate set in project. works things. today needed have query return couple hundred thousand rows table. ~2/3s of total rows in table. problem query taking ~7 minutes. using straight jdbc , executing assumed identical query, takes < 20 seconds. because of assume doing wrong. i'll list code below.

detachedcriteria criteria  =detachedcriteria.forlass(myobject.class); criteria.add(restrictions.eq("booleanflag", false)); list<myobject> list = gethibernatetemplate().findbycriteria(criteria); 

any ideas on why slow and/or change it?

you have answered own question already, use straight jdbc.

hibernate creating @ best instance of object every row, or worse, multiple object instances each row. hibernate has degenerate code generation , instantiation behavior can difficult control, large data sets, , worse if have of caching options enabled.

hibernate not suited large results sets, , processing hundreds of thousands of rows as objects isn't performance oriented either.

raw jdbc raw types rows columns. orders of magnitudes of less data.


Comments

Popular posts from this blog

c# - IMAP GMAIL getting folder list problem -

CUDA shared memory -