[Akonadi] Foreign Key support for SQLite
Closed, ResolvedPublic

Description

Apparently SQLite3 supports Foreign Keys for some time now, so we could look into using them. This would allow us to get rid of some of the manual clean ups that we have to do in order to accommodate FK-less SQLite.

https://www.sqlite.org/foreignkeys.html

dvratil created this task.Aug 28 2015, 3:59 PM
dvratil updated the task description. (Show Details)
dvratil raised the priority of this task from to Needs Triage.
dvratil added a project: KDE PIM.
dvratil moved this task to Backlog on the KDE PIM board.
dvratil added a subscriber: dvratil.
dvratil triaged this task as High priority.Aug 10 2018, 11:48 AM
dvratil moved this task from Backlog to In Progress on the KDE PIM board.
dvratil claimed this task.

Currently not having FKs means we don't even have indexes on the FK columns, which makes queries extremely slow.

The main problem is that SQLite does not support adding/removing FKs through ALTER TABLE, the only solution is to ALTER TABLE foo RENAME TO foo_old, CREATE TABLE foo ... with FKs and INSERT INTO foo SELECT * FROM foo_old, which is extremely expensive. But we don't change FKs very often and I doubt there are many people who use SQLite with large setups (maybe exactly because it's too slow), so the slow upgrade should not affect too many users. If it turns out that we are fast enough with proper FKs, I'd consider switching from MySQL to SQLite as default.

knauss closed this task as Resolved.Sep 1 2019, 3:40 PM
knauss added a subscriber: knauss.

The task with released with Application 18.12.