mysql>
select company_albums.id,company.name as company_name,company.url as company_url,company_albums.name as company_albums_name,
-> company_albums.url as company_albums_url,view_count,thumbnail_path,qq ,brand_shop_id
-> from company,company_albums
-> where company_albums.com_id=company.id
-> ORDER BY `view_count` desc
-> LIMIT 69600, 15 ;
+--------+--------------+--------------------------------+------------------------+------------------------------------------------------+------------+----------------+------------+---------------+
| id | company_name | company_url | company_albums_name | company_albums_url | view_count | thumbnail_path | qq | brand_shop_id |
+--------+--------------+--------------------------------+------------------------+------------------------------------------------------+------------+----------------+------------+---------------+
----------------------
+--------+--------------+--------------------------------+------------------------+------------------------------------------------------+------------+----------------+------------+---------------+
2 rows in set (3.10 sec)
mysql>
explain select company_albums.id,company.name as company_name,company.url as company_url,company_albums.name as company_albums_name,
-> company_albums.url as company_albums_url,view_count,thumbnail_path,qq ,brand_shop_id
-> from company,company_albums
-> where company.id=company_albums.com_id
-> ORDER BY `view_count` desc
-> LIMIT 69600, 15 \G;
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: company_albums
type: ALL
possible_keys: com_idx
key: NULL
key_len: NULL
ref: NULL
rows: 72441
Extra: Using filesort
*************************** 2. row ***************************
id: 1
select_type: SIMPLE
table: company
type: eq_ref
possible_keys: PRIMARY
key: PRIMARY
key_len: 4
ref: test_01.company_albums.com_id
rows: 1
Extra:
2 rows in set (0.00 sec)
mysql> select company_albums.id,company_albums.name as company_albums_name,
-> company_albums.url as company_albums_url,view_count,thumbnail_path,company.name as company_name,company.url as company_url,qq ,brand_shop_id
-> from company_albums ,(select company_albums.id as ca_id
-> from company,company_albums
-> where company_albums.com_id=company.id
-> ORDER BY `view_count` desc
-> LIMIT 69600, 15
-> ) as t,company where company.id=company_albums.com_id and t.ca_id = company_albums.id order by view_count desc
-> ;
2 rows in set (0.34 sec)
mysql> explain select company_albums.id,company_albums.name as company_albums_name, company_albums.url as company_albums_url,view_count,thumbnail_path,company.name as company_name,company.url as company_url,qq ,brand_shop_id from company_albums ,(select company_albums.id as ca_id from company,company_albums where company_albums.com_id=company.id ORDER BY `view_count` desc LIMIT 69510, 18 ) as t,company where company.id=company_albums.com_id and t.ca_id = company_albums.id order by view_count desc \G;
*************************** 1. row ***************************
id: 1
select_type: PRIMARY
table: <derived2>
type: ALL
possible_keys: NULL
key: NULL
key_len: NULL
ref: NULL
rows: 18
Extra: Using temporary; Using filesort
*************************** 2. row ***************************
id: 1
select_type: PRIMARY
table: company_albums
type: eq_ref
possible_keys: PRIMARY,com_idx
key: PRIMARY
key_len: 4
ref: t.ca_id
rows: 1
Extra:
*************************** 3. row ***************************
id: 1
select_type: PRIMARY
table: company
type: eq_ref
possible_keys: PRIMARY
key: PRIMARY
key_len: 4
ref: test_01.company_albums.com_id
rows: 1
Extra:
*************************** 4. row ***************************
id: 2
select_type: DERIVED
table: company_albums
type: ALL
possible_keys: com_idx
key: NULL
key_len: NULL
ref: NULL
rows: 72441
Extra: Using filesort
*************************** 5. row ***************************
id: 2
select_type: DERIVED
table: company
type: eq_ref
possible_keys: PRIMARY
key: PRIMARY
key_len: 4
ref: test_01.company_albums.com_id
rows: 1
Extra: Using index
5 rows in set (0.34 sec)
分享到:
相关推荐
MySQL性能调优与架构设计是数据库管理领域中的关键议题,特别是在处理大数据量、高并发的业务场景时,优化MySQL的性能至关重要。MySQL作为一个小型而强大的关系型数据库管理系统,被广泛应用于各种规模的企业和项目...
2. **MySQL参数调整**:如增大`Key Buffer`(MyISAM索引缓冲)、`Query Cache`(查询结果缓存)和`Sort Buffer`等,调整`Slow Query Log`阈值,优化`InnoDB Buffer Pool`大小。 3. **应用程序和架构优化**:垂直和...
MySQL数据库在软件开发中扮演着至关重要的角色,尤其是在构建高效能和高可用性的应用程序时。以下是对MySQL建表和索引使用规范的详细说明: **一、设计表规范** 1. **非空约束与默认值**:在创建表时,为确保数据...
8. **合理SQL编写**:编写高效的SQL语句,避免全表扫描,使用JOIN时要谨慎,尽量使用索引,减少子查询,避免过度复杂的查询。 9. **测试与监控**:定期进行性能测试,监控数据库运行状态,如CPU使用率、内存占用、...
HeidiSQL是一款专为MySQL设计的轻量级、高效能的数据库管理工具,它允许用户通过直观的界面来执行常见的数据库操作,如创建、修改和查询数据。 描述中提到"HeidiSQL是简单实用的MySQL数据库编辑工具",这表明该软件...
在数据库管理领域,SQL(Structured Query Language)是用于管理和处理关系型数据库的强大工具。而`EXPLAIN`命令是SQL中的一个关键功能,它允许我们分析和理解SQL查询的执行计划,帮助我们优化查询性能。本篇文章将...
- `sort_buffer_size`:设置排序操作的内存大小,值越大,排序速度越快。 - `max_connections`:限制数据库的最大连接数,避免因过多连接导致服务器资源耗尽。 - `thread_cache_size`:控制可复用线程的数量,...
【Java+MySQL CRM客户关系管理系统】是一个基于Java编程语言和MySQL数据库构建的高效能、可扩展的业务管理系统,主要用于企业对客户数据进行管理和分析。在CRM(Customer Relationship Management)系统中,关键在于...
MySQL性能优化是提升Web应用效率的关键环节,尤其是在处理大量数据操作时。以下是一些关键的优化策略: 1. **为查询缓存优化你的查询** MySQL的查询缓存能够显著提升性能,尤其是在重复查询相同数据的情况下。...