Long waits using the search method


(春节) #1

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


(Cédric Krier) #2

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.
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).


(春节) #3

Thanks, I get the idea