CoreData and inherited entities fetching unnecessary attributes
CoreData and inherited entities fetching unnecessary attributes
- Subject: CoreData and inherited entities fetching unnecessary attributes
- From: Frank Illenberger <email@hidden>
- Date: Wed, 6 Jul 2005 09:33:53 +0200
Hi,
while checking the performance of the sql statements that are issued
by CoreData to an sqlite file I discovered, that CoreData implements
entity inheritance using a single-table scheme, where the attributes
of all entities in the inheritance tree are stored in a single table.
The strange thing about this is that even when performing a fetch for
a non-base entity, the generated SELECT statement contains all the
attributes of all entities of the inheritance tree, even when it is
clear that they belong to entities that could never be reached by the
fetch.
For example:
I have a base entity named "Person" containing one string attribute
"name".
I have a second entity named "Employee" derived from "Person"
containing an additional integer attribute named "salary".
I have a third entity named "GolfPlayer" also derived from "Person"
with an additional integer attribute named "handicap".
When I now perform a fetch on the entity "GolfPlayer", the following
select statement is issued to the sqlite file:
SELECT P.Z_ENT, P.Z_PK, P.Z_OPT, P.ZNAME, P.ZSALARY, P.ZHANDICAP FROM
ZPERSON P WHERE P.Z_ENT = 3
Even though I am interested in getting only "GolfPlayer" objects
CoreData fetches the salary attribute that it knows could never be
part of a GolfPlayer object.
This is not big deal in this example. But in my application, I have a
base entity from which about twenty other entities are derived. This
results in giant fetches being issued all the time which definitely
reduces the possible performance.
Does anybody know a way to work around this? Is it possible to employ
a horizontal or vertical inheritance scheme like it is possible in EOF?
Cheers
Frank
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden