"Java" Itoo Project REAL-life Big data query using new MAP optimization hibernate cascade Query

Source: Internet
Author: User

in my last Post, " " Java " Itoo the actual project Hibernate Lazy Load Optimization Performance "I have mentioned that student data has 2 million, query data is very slow, this is a very difficult thing to see the page progress bar has been rotating circles, the feeling of anxious really can't describe. The first consideration was to use lazy to optimize, because the foreground frame reason,lazy optimization did not play anything about, and later thought there was a select New map optimization. I'll draw first. About querying students ' cascading trees


The meaning of this tree is that the depth of the student's query is 4 level.

before optimization, the hql statement for hibernate was used :fromStudent where Isdelete =? The execution of the statement, will issue a 467 statement printed to the console, playing full screen is, look at the console, look at the feeling dizzy.

when optimizing, select the selectnew Map for optimization, the statement is as follows:

Select Newmap (s.id as ID, s.name as name,s.comment as Comment,s.remark asremark,s.accountaddress as Accountaddress,s.code As Code,s.email Asemail,s.entrancedate as Entrancedate,s.graduateschool Asgraduateschool,s.identitycardid as Identitycardid,s.classes.classname Asclassname,s.classes.institution.institutionname AsinstitutionName, S.classes.institution.parentinstitution.institutionname Asparentinstitution, S.classes.institution.schoollevel.levelname Aslevelname,s.classes.institution.id as InstitutionId, S.professional.professionalcodeas professionalcode) from Student S where S.isdelete =:isdelete


When you print the statement, it is 1 article. Look at the console print out the results are very comfortable.

But their time difference is as follows:


As can be seen from the above table, the time difference is still quite a lot. Here I have something to understand :


1. When using the new map query, although only one statement is printed, it needs a full table scan, the number of queries and many, and hibernate 's hql The statement prints the statements for each query. But why is it getting longer when the query time is relative to the new map ?

2.hibernate of the hql The reason why the statement cascade query time is too long will not follow Hibernate Is there a relationship to the cache? Each query result needs to be placed in the level cache.

3. What are the reasons for the design of hibernate query statements, and what are the considerations for the design of hibernate 's Daniel?

three of the above questions I have not found the relevant information to answer, if any see, can discuss with each other .



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

"Java" Itoo Project REAL-life Big data query using new MAP optimization hibernate cascade Query

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.