WordPress管理员查询
我的 WordPress 数据库中有一个相当大的用户数据库(大约 1m)。
我在日志中看到一个缓慢的查询,它看起来像这样:
SELECT wp_users.ID,wp_users.user_login,wp_users.display_name FROM wp_users INNER JOIN wp_usermeta ON ( wp_users.ID = wp_usermeta.user_id ) WHERE 1=1 AND (
(
(
( wp_usermeta.meta_key = 'wp_capabilities' AND wp_usermeta.meta_value LIKE '%\"edit\\_posts\"%' )
OR
( wp_usermeta.meta_key = 'wp_capabilities' AND wp_usermeta.meta_value LIKE '%\"administrator\"%' )
OR
( wp_usermeta.meta_key = 'wp_capabilities' AND wp_usermeta.meta_value LIKE '%\"editor\"%' )
OR
( wp_usermeta.meta_key = 'wp_capabilities' AND wp_usermeta.meta_value LIKE '%\"author\"%' )
OR
( wp_usermeta.meta_key = 'wp_capabilities' AND wp_usermeta.meta_value LIKE '%\"contributor\"%' )
)
)
) ORDER BY display_name ASC;
我认为它是由 wp-includes/class-wp-user-query.php
制作的。我觉得这是一个用所有管理员帐户填充某些下拉列表的查询,但我一生都找不到触发它的原因。
我想找到触发它的原因并阻止它执行此查询。 (列出管理员不是我打算使用的东西。
I have a rather large user db on my WordPress database (around 1m).
I am seeing a slow query on my log and it looks like this:
SELECT wp_users.ID,wp_users.user_login,wp_users.display_name FROM wp_users INNER JOIN wp_usermeta ON ( wp_users.ID = wp_usermeta.user_id ) WHERE 1=1 AND (
(
(
( wp_usermeta.meta_key = 'wp_capabilities' AND wp_usermeta.meta_value LIKE '%\"edit\\_posts\"%' )
OR
( wp_usermeta.meta_key = 'wp_capabilities' AND wp_usermeta.meta_value LIKE '%\"administrator\"%' )
OR
( wp_usermeta.meta_key = 'wp_capabilities' AND wp_usermeta.meta_value LIKE '%\"editor\"%' )
OR
( wp_usermeta.meta_key = 'wp_capabilities' AND wp_usermeta.meta_value LIKE '%\"author\"%' )
OR
( wp_usermeta.meta_key = 'wp_capabilities' AND wp_usermeta.meta_value LIKE '%\"contributor\"%' )
)
)
) ORDER BY display_name ASC;
I think it is made by wp-includes/class-wp-user-query.php
. I feel like this is a query to populate some dropdown with all the administrator accounts, but for the life of me I cannot find out what triggers it.
I want to find what is triggering it and stop it from executing this query. (Listing admins is not something I'm intending on using.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有两个地方会使用此查询:
这里有一些代码片段(这是一个 hack),用于将这些作者列表限制为前二十个
wp_users.ID
值。查询时间将从荒谬变为快速。对于 REST 用户查询列表:
对于帖子和页面快速编辑下拉列表:
如果您的贡献者/作者/编辑/管理员不在您网站上的前 20 个用户 ID 之列,您可以使用包含其用户 ID 列表的数组代替
range(0, 20)
。There are two places where this query gets used:
Here are a couple of snippets of code (this is a hack) to constrain those lists of authors to the first twenty
wp_users.ID
values. The query times will go from ridiculous to quick.For the REST user query list:
For the posts and pages Quick Edit dropdown:
If your contributors / authors / editors / administrators aren't among the first twenty user IDs on your site, you can use an array containing a list of their user IDs in place of
range( 0, 20 )
.