# Long waits using the search method

**URL:** <https://discuss.tryton.org/t/long-waits-using-the-search-method/843>\
**Category:** Developer\
**Created:** [November 1, 2018, 6:49am UTC](https://discuss.tryton.org/t/long-waits-using-the-search-method/843 "2018-11-01T06:49:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chunjie](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/c/41988e/32.png) [@chunjie](https://discuss.tryton.org/u/chunjie)\
**Post date:** [November 1, 2018, 6:49am UTC](https://discuss.tryton.org/t/long-waits-using-the-search-method/843/1 "2018-11-01T06:49:02Z")

</div>

The wait time is too long when using search method to search for large amounts of data.  
`moves = Move.search([])`

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [November 1, 2018, 8:38am UTC](https://discuss.tryton.org/t/long-waits-using-the-search-method/843/2 "2018-11-01T08:38:30Z")

</div>

Well, `Move` is an operational table which only grows so it is expected to be slow when retrieving all of them. There are few reasons:

- it has to construct a list of all the ids in Python.
- it has to construct a list of Model instances for all the ids.

Both are memory expensive operations depending of course of the size of the table (it should stay practicable for 100K).  
Normally you should not need to perform such search without limits or clause. But if you really need such operation, it is better to chunk the result by using [limit and offset](http://docs.tryton.org/projects/server/en/latest/ref/models/models.html#trytond.model.ModelStorage.search).  
A possible improvement would be to convert `ModelStorage.search` and `ModelStorage.browse` into generators instead of returning list (or to have `ModelStorage.isearch` and `ModelStorage.ibrowse`).

---

<div class="post-metadata">

**Author:** ![chunjie](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/c/41988e/32.png) [@chunjie](https://discuss.tryton.org/u/chunjie)\
**Post date:** [November 1, 2018, 9:32am UTC](https://discuss.tryton.org/t/long-waits-using-the-search-method/843/3 "2018-11-01T09:32:19Z")

</div>

Thanks, I get the idea
