Created
November 21, 2014 06:17
-
-
Save kyu999/c1b57233ac46c303724e to your computer and use it in GitHub Desktop.
mongo_query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
課題:多くのデータがあるカテゴリーから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? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment