Details
-
New Feature
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
Description
Hello,
You know better than me which components and versions are impacted.
A few years ago, it was not available and clearly I cannot remember my bug reports or comments on MySQL (Workbench).
And I think I never did feature requests for MariaDB.
But in case, still nobody asked for it and/or implemented it at least in MariaDB,
I think it would be a nice optimization for Tiny INT columns, to have an implicit enum control.
Maintain in memory at server startup a C array of 256 booleans for each tinyint column in database.
On insert array pointer + offset tells you if you modified your implicit enum regarding this tiny int column (many statuses fields in database are tiny int, it was the case in my previous work at Teliae, because enums were too recent).
Use this implicit enum knowledge to replace negative logic queries like my_field != 1 by my_field IN (2,3,4) when the implicit enum has possible values 1,2,3,4 to have "searchable queries" using indexes.
Technically, you could have this logic only on indexed queries, but maybe coupling it would slowdown or complicate some migrations or index switches.
It's late and I don't know exactly for that, so I expect you will look at the possibilities between 1) this logic on all tiny ints, 2) this logic activated independently but explicitly on some tiny ints columns or 3) only on columns with indexes (note that index may be a forcing case for the second case 2) ), and make a wise choice like a database option for 1,2 or 3
with an implicit 2) behind.
Maybe it would be also efficient for values in INT16 (sparse ?) and sparse INT32 or INT64 but it would need to handle sparseness and branching out of this optimisation on some threshold, etc.
Probably nice for all users of frameworks that don't have INT8 or even INT16 in ORM out there XD...
Best regards,
Laurent Lyaudet