CoreData 属性的索引属性有什么作用? [英] What does the Indexed Property of a CoreData attribute do?

查看:19
本文介绍了CoreData 属性的索引属性有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有 32 位哈希值的核心数据模型.我需要快速查找特定的哈希值.我应该使用索引属性吗?我不知道它做什么和 .

简而言之,数据库引擎创建了一个新结构,它使索引列(对应于一个属性)保持排序,并为每个条目(主键)提供一个指向相应行的链接.这允许更快的搜索(因为在有序列表中搜索比在无序列表中搜索更快).但这会增加使用的存储空间(用于数据结构)和插入时间(以保持结构有序).

所以是的,你应该在这种情况下使用索引.

I have a Core data model with a 32bit hash value. I need to look up specific hash values quickly. Should I use the indexed property? I have no idea what it does and the documentation is no help (am I looking in the wrong place?)

So what does indexed do exactly?

解决方案

I would recommend to read this on indexes: http://en.wikipedia.org/wiki/Index_(database)

Simply put, a database engine creates a new structure which keeps the indexed column (which corresponds to a property) sorted and a link to the corresponding row for each entry (primary key). This allows for faster searches (since search in ordered lists is faster than in unordered lists). But this increases used storage (for the data structure), and insertion times (to keep the structure sorted).

So yes, you should use indexes in such cases.

这篇关于CoreData 属性的索引属性有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆