-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.10.1: finding next sequential order number super-slow (15 min) on postmeta model with high row count #36
Comments
This query suffers from the curse of the key-value store in MySQL / MariaDB. If this were my code, I would have figured out how to use an autoincrementing number (a/k/a (Beware, I have not seen the surrounding application code so I'm not super well informed on this situation.) There's a robust hack to do this sequence generation in all versions of MySQL / MariaDB, written up here. https://stackoverflow.com/questions/27867980/what-is-the-difference-between-oracles-sequence-and-mysqls-auto-increment-fe/27868057#27868057 |
This looks fairly solid, but seems to require maintaining a separate db table, correct? And each unit / plugin that wants to have a unique sequence, would need its own table, correct? |
I see now this plugin has a Marketplace version with Performance Mode https://woo.com/document/sequential-order-numbers/#section-11 I've purchased and will test it immediately. |
Yes, the "robust hack" I mentioned does require a distinct table for each distinct sequence of integers. The tables don't grow large, so there's no storage penalty. A plugin that used the hack would have to create those tables. MariaDB 10.6.1 and beyond has a built-in SEQUENCE object (like the Oracle object) that removes the need for the "robust hack". https://mariadb.com/kb/en/sequence-overview/ But many WordPress sites run on DBMS versions without that feature. |
This query is currently taking 15 minutes to execute on our live server, with millions of posts, few tens of millions of postmeta rows.
What can we do to improve this query on postmeta, other than HPOS migration (it's roadmapped, but not immediate)?
EXPLAIN
below:The text was updated successfully, but these errors were encountered: