`
ws00739818
  • 浏览: 2801 次
  • 性别: Icon_minigender_1
  • 来自: 成都
文章分类
社区版块
存档分类
最新评论

Chapter 20. Improving performance

阅读更多
1.抓取策略
抓取策略声明在O/R映射的元数据中,或在在特定的HQL 或条件查询中重载声明。

Join fetching:用out join同时查询出关联的对象或集合

Select fetching: 另外发送一条 SELECT 语句抓取当前对象的关联实体或集合。除非你显式的指定lazy="false"禁止 延迟抓取(lazy fetching),否则只有当你真正访问关联关系的时候,才会执行第二条select语句。

Subselect fetching:另外发送一条SELECT 语句抓取在前面查询到的所有实体对象的关联集合。除非你显式的指定lazy="false" 禁止延迟抓取(lazy fetching),否则只有当你真正访问关联关系的时候,才会执行第二条select语句。

Batch fetching:优化的抓取策略,通过一组(list)主键或外键,一次查询出一批实例。
batch-size属性,可以批量加载实体类,参见:Classes.hbm.xml
<class name="Classes" table="t_classes" batch-size="3">

从另一个角度来看,hibernate的fetching 分成以下几种。

•Immediate fetching: 如果实体已经被加载了,他的关联对象,关联集合,属性也要及时加栽。
•lazy collection fetching: 只有应用程序真正使用这个集合的时候,才加栽这个集合。
•"Extra-lazy" collection fetching : hibernate 不加载一个集合的所有对象到内存里,需要哪个个体,加载哪个。
•Proxy fetching :当前对象的单值相关对象只有在调用它的主键外的其他属性的get方法时才加载它。
"NO-proxy"fetching :当前对象的单值相关对象在它的实体变量被访问的时候就被加载。相对于Proxy fetching来说,"No-proxy" Proxy fetching更延迟。(因为"NO-proxy"fetching即使是访问关联对象的主健,关联对象都要被加载)。"NO-proxy"fetching对于应用来说更条理清晰。因为在应用中没有一个可见的proxy.
      个人认为可以这样理解上述情况,假如在数据库中存在两张表 A,B.表A中有一个指向表B主健的外键。如果想知道A表中的某条数据对应B表中的那条记录的主键。完全不用访问B表,A表中的此条数据的外键值就是B表中对应数据的主键。所有只有访问B表中对应数据的主键外其他属性时,才需要加载B表中的这条数据。

•Lazy attribute fetching :当前对象的某个属性或单值相关对象只有在与它对应的实体变量被访问的时候才加载。


分享到:
评论

相关推荐

    Mastering ElasticSearch 5.0, 3rd Edition

    Title: Mastering ElasticSearch 5.0, 3rd Edition Author: Bharvi Dixit Length: 508 pages ... Improving Performance Chapter 11. Developing Elasticsearch Plugins Chapter 12. Introducing Elastic Stack 5.0

    Swift.High.Performance.1785282204

    This book is aimed at experienced Swift developers wanting to optimize their programs on Apple platforms to optimize application performance. What You Will Learn Build solid, stable, and reliable ...

    MATLAB for Machine Learning

    Title: MATLAB for Machine Learning Author: Giuseppe Ciaburro ... Improving The Performance Of The Machine Learning Model - Dimensionality Reduction Chapter 9. Machine Learning In Practice

    Mastering.Oculus.Rift.Development.epub

    Improving Performance and Avoiding Discomfort Chapter 4. Interacting with Virtual Worlds Chapter 5. Establishing Presence Chapter 6. Adding Depth and Intuition to a User Interface Chapter 7. Hearing ...

    Packt.Mastering.Windows.Presentation.Foundation.2017 pdf文字版

    The final section of the book demonstrates ways to polish your applications, from adding practical animations and data validation to improving application performance. The book ends with a tutorial on...

    Mastering Windows Presentation Foundation

    The final section of the book demonstrates ways to polish your applications, from adding practical animations and data validation to improving application performance. The book ends with a tutorial on...

    Learning.PHP.7.High.Performance.1785882260

    Next, we will shed some light on how to improve your PHP 7 applications' performance and database performance. Through this book, you will be able to improve the performance of your programs using ...

    PHP.Beyond.the.Web

    Performance & stability - profiling and improving Chapter 10. Distribution and deployment issues Chapter 11. Where now? or, Thanks & feedback Appendix A : Compiling and installing ...

    Entity.Framework.Core.Cookbook.2nd.Edition

    With the concluding chapter on performance and scalability, this book will get you ready to use Entity Framework proficiently. What you will learn Master the technique of using sequence key ...

    Chapter 5 - Improving Managed Code Performance.pdf

    源自微软官方文档 提升托管代码性能PDF文件。源自微软官方文档 提升托管代码性能PDF文件。源自微软官方文档 提升托管代码性能PDF文件。

    Distributed.Computing.with.Python.178588969

    This book will teach you how to perform parallel execution of computations by distributing them across multiple processors in a single machine, thus improving the overall performance of a big data ...

    Practical Mod Perl

    Improving Performance with Shared Memory and Proper Forking Section 10.1. Sharing Memory Section 10.2. Forking and Executing Subprocessesfrom mod_perl Section 10.3. References ...

    Developing Flex Applications 910p dda_doc88_cracker.zip

    Improving application start-up time and performance. . . . . . . . . . . . . . . . . . . . . . 78 Summary of Flex application features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....

    pro_apache_third_edition..pdf

    Special IP Addresses..........................................................................................20 Netmasks and Routing......................................................................

    Drupal.8.Development.Beginners.Guide.2nd.Edition.epub

    The new version brings significant changes to its module development and theme creation techniques, improving performance and refining the development experience. This book will help you develop ...

    High Performance in-memory computing with Apache Ignite.pdf

    Sharing Spark RDD states between different Spark applications for improving performance. Processing events & streaming data, integrate Apache Ignite with other frameworks like Storm, Camel, etc. ...

    Signal Integrity - Simplified(Eric Bogatin).pdf

    Translating Physical Design into Electrical Performance Section 4.2. The Only Good Approximation for the Resistance of Interconnects Section 4.3. Bulk Resistivity Section 4.4. Resistance per Length ...

    GNU make 项目管理

    Chapter 10: Improving the Performance of make Chapter 11: Example Makefiles Chapter 12: Debugging Makefiles Part III. Appendixes A. Running make B. The Outer Limits C. GNU Free Documentation License-...

    PHP.7.Real.World.Application.Development

    Chapter 4: Improving Database Performance Chapter 5: Debugging and Profiling Chapter 6: Stress/Load Testing PHP Applications Chapter 7: Best Practices in PHP Programming Appendix A: Tools to Make Life...

    Microsoft SharePoint 2010 Administrator's Companion

    Topics include architecture, deployment scenarios, design considerations, security best practices, high availability, performance, centralized administration, disaster recovery, customization, ...

Global site tag (gtag.js) - Google Analytics