优化 MySQL 查询对 GROUP BY 3 Tables Count 中的结果进行排序

发布于 12-17 12:46 字数 720 浏览 3 评论 0 原文

我有以下疑问:

SELECT contry, count(contry) as 'N'
FROM user_ip_tmp 
GROUP BY contry
ORDER BY count(contry) DESC
LIMIT 40

SELECT iconOperation, count(iconOperation) as 'N'
FROM user_ip_tmp 
GROUP BY iconOperation
ORDER BY count(iconOperation) DESC
LIMIT 40

SELECT iconBrowser, count(iconBrowser) as 'N'
FROM user_ip_tmp 
GROUP BY iconBrowser
ORDER BY count(iconBrowser) DESC
LIMIT 40

并且工作正常 但疯狂的原因 Query take Large 每个查询

Showing rows 0 - 29 ( 40 total, Query took 2.2857 sec)

意味着所有查询的总数查询花费了15.661秒

我想合并查询中的所有狂欢一个查询

最终结果如下

在此处输入图像描述

I have the following query:

SELECT contry, count(contry) as 'N'
FROM user_ip_tmp 
GROUP BY contry
ORDER BY count(contry) DESC
LIMIT 40

SELECT iconOperation, count(iconOperation) as 'N'
FROM user_ip_tmp 
GROUP BY iconOperation
ORDER BY count(iconOperation) DESC
LIMIT 40

SELECT iconBrowser, count(iconBrowser) as 'N'
FROM user_ip_tmp 
GROUP BY iconBrowser
ORDER BY count(iconBrowser) DESC
LIMIT 40

And working properly
But the delirious cause Query took Large
Each query

Showing rows 0 - 29 ( 40 total, Query took 2.2857 sec)

Meaning that the total of all queries up Query took 15.661 sec

I want to merge all the rave in the queries one query

Final results appear as follows

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绿光 2024-12-24 12:46:54

如果您的意思是所有 6 列一起显示为一个记录集,其中一行包含国家/地区及其计数,然后是浏览器及其计数,然后是操作系统及其计数,我目前不认为这是可能的。除了没有太大帮助的表名称之外,可以链接在一起的集合之间似乎没有任何关系。如果可以的话,请建立这些查询之间的关系:)

If you mean for all 6 columns to appear together as one recordset where one row has the country and its count followed by the browser and its count followed by the os and its count, I don't see how that's possible at the moment. There doesn't seem to be any relationship between the sets that can be linked together apart from the table name which isn't much help. If you can, please establish the relationship among these queries :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文