Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
145 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...