views:

31

answers:

1

Hi,

I'm looking into storing lots of number as Int16. Considering Core data because the rest of the models are implemented in Core data.

So I did a simple application. Core data with 1 entity and 1 attribute of Int16 type. Inserted 1 million entries in SQLite storage type and the file size turns out to be 16.2MB. Actually if I change to Int64, I would get the same file size. If writing simple binary C array, should be around 2MB.

So question is, why did Core data bother with so many different kind of number format if everything will be casted to NSNumber anyway? And is there any way to make Core data store the data as true Int16? or short in C terms?

Thanks.

+2  A: 

Just because Core Data supports all those number formats doesn’t mean the underlying storage engine has to store them in a different way. If you tried using the binary store you’d probably get different file sizes.

For storing that many integers I would put them all in a NSData object and store this in Core Data.

Sven
That is a great idea! Now the data file is only 2.1MB. Only 100KB overhead, well worth it for the convenience.
Dan