What are Indexes in the Xcode Core-Data data model inspector

前端 未结 3 2024
野的像风
野的像风 2021-02-12 10:54

In Xcode you can add \"Indexes\" for an entity in the data model inspector.

\"Xcode

3条回答
  •  轮回少年
    2021-02-12 11:14

    Adding a row with a single attribute to the Indexes list is equivalent to selecting Indexed for that attribute: It creates an index for the attribute to speed up searches in query statements.

    The Indexes list is meant for compound indexes. Compound indexes are useful when you know that you will be searching for values of these attributes combined in the WHERE clause of a query:

    SELECT * FROM customer WHERE surname = "Doe" AND firstname = "Joe";
    

    This statement could make use of a compound index surname, firstname. That index would also be useful if you just search for surname, but not if you only search for firstname. Think of the index as if it were a phone book: It is sorted by surname first, then by first name. So the order of attributes is important.

提交回复
热议问题