[wp-trac] [WordPress Trac] #36866: Add another index to usermeta table
WordPress Trac
noreply at wordpress.org
Thu Aug 28 22:09:00 UTC 2025
#36866: Add another index to usermeta table
-------------------------+----------------------
Reporter: mnelson4 | Owner: (none)
Type: enhancement | Status: closed
Priority: normal | Milestone:
Component: Database | Version:
Severity: normal | Resolution: invalid
Keywords: | Focuses:
-------------------------+----------------------
Comment (by curtisfraser):
Adding the index within core is a good idea. Efficiency is a good thing.
I would go a little further though. The combination user_id+meta_key
should be unique, therefore a key should be created, which is then
indexed.
However the size of meta_key(255) poses a problem. This should be set to
150. Then regardless of data type, a key can be created and it can be
indexed.
Then plugins can use a simple SQL for insert/update:
INSERT INTO wp_usermeta (user_id, meta_key, meta_value)
VALUES ('UserID', 'your_meta_key', 'your_value')
ON DUPLICATE KEY UPDATE meta_value = VALUES(meta_value);
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36866#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list