A partial index helps to have smaller indexes, and makes INSERTs faster.
For instance
CREATE TABLE wine (
name VARCHAR(100),
...
INDEX (name(8)));
While names are something like
Chateau Mouton-Rothschild Chateau Mouton-Cadet Chateau Petrus Chateau Lafite Chateau Lafleur ...
In this (example) list, Chateau appears all the time, MySQL creates an index based on the 8 first characters… meaning there will be only one entry in the index (and the search of Chateau Petrus will be done sequentially for all Chateau).
(In this very case, a split between the first word (Chateau) and the rest of the name in two fields would make sense, but this is not the point).
Is there a way to ask MySQL to create a partial index based on the end of a field?
Actually I found a way in the meantime – with a bit of programming:
Only for the
namefieldnameentries are stored reverse in the DBnamesearches are made reversenamein row is reversed before being sent to client (user agent)For instance in PHP
...query('INSERT ... name="' . strrev($name) . '"......query('SELECT * FROM wine WHERE name="' . strrev($name) . '"');%MOUTON%will actually search%NOTUOM%There is a bit of
reverseoverhead, but is negligible compared to the possible database gain.The question was specifically asking for a pure MySQL solution, but if there is none, this is a workable workaround in any language. I’ll accept this answer in a few days if there is nothing better.