Optimization principle of--orm framework query in Java Engineering optimization

Source: Internet
Author: User

It is well known that in today's popular enterprise architecture, ORM has always been the most basic part, at the bottom of the architecture design, providing object-oriented operational support to the logical layer, and the fact is always biased with our expectations, ORM in providing a better operating experience, also lost a part of native SQL flexibility and efficiency, Of course, this problem does not affect our use of ORM framework, but it hinders our website traffic, especially in the enterprise-level multi-relational complex query, performance bottleneck is the part to be mentioned!

In response to this problem, most ORM frameworks provide a compromise solution, which is to construct an object in the query statement, either an entity or a map, which solves the problem of cascading queries to a large extent, and today we come together to uncover this veil and see the optimization here. How it's done!

Phenomenon:

Let's take a look at some of the entities we used in our experiment.



You can see the middle of the student entity, and other entities associated too much, if we use the general query will become very slow, we test in Query 10 records, do not open lazy loading premise, 10 minutes of these data can not be loaded, we look at the log file, the SQL statement sent:

cause

Query statement:

From Student where isdlete=0

Log file:


This is only a small part, we do the statistics is issued 241 query statements, the results are not tolerated by the customer, through the study, we found that the direct send from although can return objects, but seriously slow query efficiency, in front of the Add SELECT statement, will be much better, Because add select, it will be combined into a join statement, and finally only one day SQL statement, the efficiency of the increase is obvious!

Summary:

A problem of the solution, sometimes very simple, but also to their original design remorse, in fact, this is a process, a wealth, we encounter every problem, is to let us in the future design has a better idea, of course, the more important thing is that others hit the beaten experience as their own experience , enhance their ability, this is also the enterprise like to see!

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

Optimization principle of--orm framework query in Java Engineering optimization

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.