English subtitles

← Indexes - Developing Scalable Apps with Java

Get Embed Code
6 Languages

Showing Revision 5 created 05/25/2016 by Udacity Robot.

  1. All data store queries are performed using indexes,
  2. and knowing how they work is important when you
  3. design and build your applications. If you have
  4. worked with a relational database management system, and SQL.
  5. You should be aware that those indexes are
  6. not the same as data store indexes. Indexes in
  7. RDBMS are a query optimization used to retrieve your
  8. result faster. While indexes in Datastore are, in fact,
  9. required to perform a query on that data at all. So you if you want to query for
  10. Datastore data, there has to be an index for
  11. that data. Be sure to remember this. So let's
  12. look at Datastore indexes by going back to conferences.
  13. And look at what happens when we perform a
  14. search on the property city. In fact, let's even
  15. talk about what happens before the query. When storing entities,
  16. Datastore also updates index tables, which are
  17. later used to find entities when the query
  18. is made. These index tables consist of an
  19. index value, that maps to a matching entity
  20. key. Taking the city Berlin as an example,
  21. the index value would be constructed using the
  22. kind, conference. Then the property, city, and finally
  23. the value of the property, Berlin. Here are
  24. the index values for the cities Halloween,
  25. London, and Paris. So again, the index value
  26. is a combination of the kind, property, and
  27. value of the property. Each index value then
  28. points to the entity key where the value
  29. resides. So a matching entity where city is
  30. Berlin has the following key. And one with
  31. London has the following key, and so on.
  32. So let's say your favorite city is, Paris.
  33. And you would like to get all conferences that
  34. are in Paris. Then Datastore would look at the
  35. index table where city is Paris, and find all
  36. matching entities. Since data store require index tables
  37. to perform queries, every property that you query for
  38. will need an index table. By default, Datastore creates
  39. these automatically. But we will also see how you
  40. can control this later on.