The database schema is not a secret. If it helps, I can post it, that's no 
problem. Is it enough to run ".dump" on a database without data?

----- Original Message ----- 
From: Keith Medcalf <kmedc...@dessus.com>
To: SQLite mailing list <sqlite-users@mailinglists.sqlite.org>
Sent: Friday, November 1, 2019, 22:57:02
Subject: [sqlite] DELETE extremely slow


On Friday, 1 November, 2019 15:12, Simon Slavin <slav...@bigfraud.org> wrote:

>So the slow-down in the DELETE FROM command is caused by a TRIGGER, but
>there are no TRIGGERs on DELETE ?  I don't understand that.  Can someone
>explain, please ?

The code indicates that they are AFTER DELETE so presumably they are triggers, 
though they are fkey.abort and .abort, so they may be also the result of the 
implementation of ON DELETE conditions, which are internally implemented by 
sub-programs and cannot really be distinguished from triggers without seeing 
the full schema.  You might be able to tell if explain comments were enabled at 
compile time (SQLITE_ENABLE_EXPLAIN_COMMENTS), though I can't really say 
whether the extra comments would make it obvious or not without being able to 
see the actual schema or doing a more detailed analysis of the VDBE code.

Foreign key constraints are processed in-line since the default condition is to 
abort/rollback the entire statement only if the fkey violation count is not 
zero at the end of the statement execution.  If you have ON conditions attached 
to the foreign key constraint, they are implemented by a sub-program called 
after the processing of each row rather than inline.  This means, for example, 
that if you have ON DELETE RESTRICT specified against a foreign key constraint 
that a statement which has no violations will effectively be "half as 
efficient" as one that does not have ON DELETE RESTRICT because extra 
constraint will be implemented as a sub-program that will re-check the 
constraint during statement execution so that an immediate ABORT can be raised 
... or at least I think that is how it is implemented.  The same applies for ON 
... CASCADE or ON ... SET NULL which must be implemented as a sub-program run 
per-row and is not easily distinguishable from a trigger which implements the 
same functionality.

-- 
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.



_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to