Open anigeluk opened 6 years ago
I'd be happy to accept a PR to address this, though activation hook is not ideal as they are not triggered for mu-plugins. We could go the route of an option in the DB that tracks if the DB table has been installed. Or, we could just object-cache the existence of the table so it's not making the SQL query all the time.
The code is currently running a query to create a DB table if doesn't already exist on
admin_init
.https://github.com/humanmade/protected-embeds/blob/32f1e61af00d8ab0e86764b29e87077956911515/protected-embeds.php#L14
Due to how often
admin_init
is triggered this is potentially creating a large number of unnecessary queries, for instance we have literally seen thecreate_database_table()
function called millions of times in a single day on one of our big sites.It would be more efficient to check the table exists on activation and upgrade rather than on every admin action.
Please give me a shout if you would like me to work on this with you.
Thanks.