防止核心数据将实体合并到一个表中 [英] Prevent Core Data From Combining Entities into One Table

查看:101
本文介绍了防止核心数据将实体合并到一个表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法告诉Core Data,当他们都继承自一个基本实体时,不把你的所有实体放入一个表?这里有一个例子:我们有一个Entity对象,我们有一个Person和Product继承自Entity。核心数据创建一个ZENTITY表,其中包含实体,人员和产品的组合字段。我们想要的是核心数据创建两个单独的表,一个用于人员,一个用于产品。

Is there a way to tell Core Data to not put all your entities into one table when they all inherit from a base entity? Here's an example: We have an "Entity" object and we have a "Person" and "Product" that inherit from "Entity". Core data creates an ZENTITY table with the combined fields for "Entity", "Person" and "Product". What we want is for core data to create two separate tables, one for "Person" and one for "Product".

这是可能吗?没有任何地方在线谈论这个...

Is this even possible? Nothing anywhere online talks about this...

推荐答案

我做了测量和CoreData的性能完全退化时, 50000个对象,20多个类,每个具有〜5个关系,大多数是多对)数据。我不使用CD的玩具应用程序与1000个对象 - 这是一个真正的巨大的应用程序和性能的虚拟是不合理的。更糟糕的是,创建小对象需要大量的ssd和内存空间,因为这个愚蠢的实现。

I did measurements and CoreData's performance is totally degraded when using inheritance on real (~50000 objects, 20+ classes, each having ~5 relationships, most of them to-many) data. I do not use CD for toy apps with 1000 objects - it's a real huge app and performance penality is unjustified. Even worse, creating small objects takes lots of ssd and memory space because of this stupid implementation.

唯一真正的解决方案(我需要继承)是替换默认的sqlite持久存储与手动实现使用NSIncrementalStore从iOS 5及以上。但是,对SQL转换和模型更新的读取请求实际上很难实现。

The only real solution (i DO NEED inheritance) is to replace the default sqlite persistent store with manual implementation using NSIncrementalStore from iOS 5 and up. However, fetch request to SQL translation and model updates are really hard to implement.

是的,我知道核心数据不是一个SQL。但我希望它在处理大量数据时工作速度相当快 - 否则在现实世界的应用程序中使用它是愚蠢的。

And yes, i know that core data is not an SQL. But i expect it to work comparably fast when dealing with lots of data - otherwise it would be stupid to ever use it in real world apps.

这篇关于防止核心数据将实体合并到一个表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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