Grails 1.3.7 +如何停止Creatcriteria的执行 [英] Grails 1.3.7 + how to stop the execution of Creatcriteria

查看:124
本文介绍了Grails 1.3.7 +如何停止Creatcriteria的执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Grail 1.3.7



我正在为具有大量数据集的域对象执行createCriteria。并花费很长时间来获取结果。



如何停止执行。或者是否有其他的实施方式。



感谢
Santosh

解决方案 div>

我不知道Grails中有哪些功能可以让您取消长时间运行的查询。对于初学者来说,在Criteria中调用 list()不会返回,直到从数据库中获取所有请求的结果。我认为你需要把重点放在让查询的表现更好的事情上:




  • 显然,如果可能的话,添加更多条件限制行

  • 使用 maxResults 限制返回的行数
  • 如果您不需要域对象中的所有值,请使用属性投影来防止创建域对象并减少内存

  • 如果您需要迭代大量数据,使用 scroll()并定期 flush() clear()会话以防止经济放缓。


I am using Grail 1.3.7

I am executing the createCriteria for domain object which is having large set of data. and taking long time to fetch the results.

How to stop the execution. or is there any other way of implementation.

Thanks Santosh

解决方案

I'm not aware of any functionality in Grails that allows you to cancel a long running query. For starters, calling list() on a Criteria will not return until all the requested results are fetched from the database. I think you need to focus on things that will make the query perform better in the first place:

  • Obviously, add more criteria, if possible to restrict the rows
  • Use maxResults to limit the number of rows returned
  • If you don't need all the values in the domain object, use property projection to prevent having to create domain objects and reduce memory
  • If you need to iterate over a large set of data, use scroll() and periodically flush() and clear() the session to prevent slowdown.

这篇关于Grails 1.3.7 +如何停止Creatcriteria的执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆