Exporting data to google sheet

后端 未结 1 1661
情话喂你
情话喂你 2021-01-16 07:00

This is more about performance. This is the scenario:

This app is used to control the inventory of PCs in an organization. So the app has a model that consists of 32

相关标签:
1条回答
  • 2021-01-16 07:44

    First things first I would recommend to find bottlenecks in your code. For instance you can try to use console.time and console.timeEnd to log execution times. Once you know where are the slowest parts of your algorithm you can tackle how to improve them.

    Second thing to try is to use prefetch. It seems, that now your script makes a call to the database to access relations for each record. So, total number of calls to DB is N * M + 1, where N is total number of records, M is number of relations for each record and 1 is the initial call to get records without relations.

    var query = app.models.pcItems.newQuery();
    query.prefetch.myModel._add();
    
    var pcItems = query.run();
    
    for (...) {
    
    ...
    
    // after adding prefetch this line should not cause additional
    // call to the database
    hist = item.itemHistory; 
    
    ...
    }
    
    0 讨论(0)
提交回复
热议问题