Use virtual index instead of triggers

Created on 17 March 2021, almost 4 years ago
Updated 11 September 2024, 3 months ago

Problem/Motivation

Triggers are not supported everywhere but with MySQL 5.6 reached EOL in February 2021 we can require MySQL 5.7 and use virtual index.

Proposed resolution

InnoDB supports secondary indexes on virtual generated columns. Other index types are not supported. A secondary index defined on a virtual column is sometimes referred to as a β€œvirtual index”.
See https://dev.mysql.com/doc/refman/5.7/en/create-table-secondary-indexes.html

As for PostgreSQL, just join on the CAST expression without any tricks because PostgreSQL can index on such a thing. In late 2023 when MySQL 5.7 is EOL and hopefully MariaDB catches up too, we can drop the generated column and standardize on this -- MySQL 8.0 can index on expressions right now, MariaDB can't.

Remaining tasks

Finilize the apporoch.
Create a patch
Add upgrade path
Create a new branch. maybe
Commit
Release
Rejoice

User interface changes

None

API changes

Triggers will be removed.
Virtual Index will be used.

Data model changes

Extra string column for target ID becomes maintained by the database without triggers.

πŸ“Œ Task
Status

Active

Version

4.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada jibran Toronto, Canada

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024