Slee
Slee

Reputation: 28268

using SQL to directly delete CoreData data from my DB

There are times when i will need to delete say 10,000 rows from my CoreData data store and looping through those records individually each time takes way too long.

Is there a way to use SQL to directly delete from my data store quickly?

Upvotes: 0

Views: 211

Answers (1)

James
James

Reputation: 2376

Modifying the CoreData store directly risks corrupting the database and is very highly discouraged. Your best bet is to delete with a CoreData query that is able to select all of the rows to be deleted at once.

When I say it risks corrupting, I don't mean that anything would be wrong with your SQL query, but that CoreData also inserts a lot of metadata into the database to help its indexing.

Upvotes: 1

Related Questions