On 31 Oct 2019, at 9:51am, Thomas Kurz <sqlite.2...@t-net.ruhr> wrote:

> I'm using a database with 5 hierarchically strcutured tables using foreign 
> keys. The largest table contains about 230'000 entries. My problem is that 
> deleting in this database is extremely slow:

Keith found the answer: you don't have the indexes required to make your 
FOREIGN KEYs run quickly.  But I have a question:

If you DELETE FROM the child tables first, do you get fast or slow times ?

Thee way you're doing it involves a lot of steps as SQlite works its way 
through the parent table, deletes one row from that, and cascades through the 
other tables, looking for and deleting related rows from those.

SQLite has an optimization for DELETE FROM without a WHERE clause.  But I don't 
know if it's smart enough to realise that if you do that to a parent table, you 
can also do it to all child tables.  Or perhaps its not true and there might be 
child rows with no parent row, and SQLite is making sure it preserves them.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to