Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Thomas L
2,366 PointsWhat are some best practices to create efficient Parse.com queries?
Say the Ribbit app grows to have 10K users. Now if you were to always scan through all 10k users everytime you open the app, I assume this would not work out well.
Can anyone with experience with this type of database querying point us in the right direction for how to handle this issue?
For example, how can you structure your friends relations in the Ribbit app on Parse so that it indexes efficiently when querying the database for your friends?
Thomas L
2,366 PointsThanks for the ideas and I hope Treehouse can post a workshop on this!
2 Answers
JT Keller
12,731 PointsIt looks as though parse.com doesn't use a traditional relational database such as MySQL or PostgreSQL, instead it uses MongoDB (https://parse.com/questions/which-type-of-database-does-parse-use-sql-or-nosql) , which falls into the NoSQL category. You can find out more about it here: http://docs.mongodb.org/manual/faq/fundamentals/. In terms of optimization, you don't need to do anything...that's the beauty of SaaS. You only need to worry about optimizing your code on your end and let parse and Mongo handle the rest.
Thomas L
2,366 PointsThanks for the guidance! Time to go have another read now.
Valery Kukatov
6,996 PointsValery Kukatov
6,996 PointsI don't know the answer and would like to know it myself, but I would guess that the database does not have to scan the entire 10k users, especially once it has already done it before. When you log in it would only scan for your friends, not an entire database. Or even possibly each user will have their own database, so the app doesn't look through 10k. The other thing, may be it will just cache the database, but that'd be just odd, especially if it's that big.
I'm most likely wrong, that's why this is just a comment, but I am curious as to what the actual answer will be. Thanks for posting. :)