kyu999
11/21/2014 - 6:17 AM

mongo_query

mongo_query

課題:多くのデータがあるカテゴリーから12個のデータを各ページにて取り出すときに毎度find queryを発行していては遅すぎるしアクセスが増えた時にすぐ死ぬる。

解決方針:

 1. if(iterator does not take so much time to extract even 1000 data) get iterator and pass through it to another page
   => what about the user visit the first page and go to the last page? => out?
   
 2. slice index the page => if page is 3, the data to slice is 3 * 12 to (3 + 1) * 12. 
   page : 1 ->  1 * 1 to 1 * 12 = 1 to 12
   page : 2 ->  (2 - 1) * 12 to 2 * 12 = 12 to 24
   page : 3 ->  (3 - 1) * 12 to 3 * 12 = 24 to 36
   
   * if the slice include the last page of index(if page is 1, whether the slicing include the 12th data or not)
       => if so, just minus 1 from the first part like (2 - 1) * 12 - 1
       
  => cache cursor?