I am facing performance issue with fetching and saving images in Core Data.
I have a Core Data entity that contains user's profile. Profile
includes one photo of the user and other details of him such as name, address etc.
For example, a row in the entity would look like as below.
Name, Address, Image, Details
If I remove the image, everything works fast. After adding image, each row takes around 1 ~ 5 seconds to be retrieved. The time lag depends on the size of the image that user uploaded (I verified time taken with and without image using Instruments).
I am storing the image as Transformable.
I tried fixing the issue by storing the image as binary data and using UIImagePNGRepresentation
. However, the issue became worser.
How to resolve this performance issue? I want to retain the image in Core Data itself due to the design of the app.