Oracle的SQL语句执行效率问题查找与解决方法
2009-03-02 21:59
1106 查看
跟一个朋友,不错公司的主管交流时,对于mysql中条件查询和排序时 与索引的关系
mysql> explain select * from article where title='希望光伏企业挺过2个月' o
rder by id desc\\\\\\\\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: article
type: index
possible_keys: NULL
key: PRIMARY
key_len: 4
ref: NULL
rows: 567
Extra: Using where
1 row in set (0.00 sec)
mysql> select * from article where title='希望光伏企业挺过2个月';
+----+-------------+---------+--------+-----------------------------+----------+
-----------+-------+-------------+---------+---------+--------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------+--------+--
---------+--------+------------+------------+
| id | category_id | user_id | app_id | title | subtitle |
professor | money | cooperation | project | address | discription
| source | r
ecommend | status | ctime | mtime |
+----+-------------+---------+--------+-----------------------------+----------+
-----------+-------+-------------+---------+---------+--------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------+--------+--
---------+--------+------------+------------+
| 10 | 2 | 4 | 0 | 希望光伏企业挺过2个月 | |
| 0 | | | | 希望企业挺过两个月。 | |
1 | 0 | 1371524848 | 1371525226 |
+----+-------------+---------+--------+-----------------------------+----------+
-----------+-------+-------------+---------+---------+--------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------+--------+--
---------+--------+------------+------------+
1 row in set (0.00 sec)
mysql> explain select * from article where title='希望光伏企业挺过2个月';
+----+-------------+---------+------+---------------+------+---------+------+---
---+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | ro
ws | Extra |
+----+-------------+---------+------+---------------+------+---------+------+---
---+-------------+
| 1 | SIMPLE | article | ALL | NULL | NULL | NULL | NULL | 5
67 | Using where |
+----+-------------+---------+------+---------------+------+---------+------+---
---+-------------+
1 row in set (0.00 sec)
大部门的开发人员会认为第一种查询时,不会用到索引
本文出自 “Linux运维” 博客,请务必保留此出处http://2853725.blog.51cto.com/2843725/1562343
mysql> explain select * from article where title='希望光伏企业挺过2个月' o
rder by id desc\\\\\\\\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: article
type: index
possible_keys: NULL
key: PRIMARY
key_len: 4
ref: NULL
rows: 567
Extra: Using where
1 row in set (0.00 sec)
mysql> select * from article where title='希望光伏企业挺过2个月';
+----+-------------+---------+--------+-----------------------------+----------+
-----------+-------+-------------+---------+---------+--------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------+--------+--
---------+--------+------------+------------+
| id | category_id | user_id | app_id | title | subtitle |
professor | money | cooperation | project | address | discription
| source | r
ecommend | status | ctime | mtime |
+----+-------------+---------+--------+-----------------------------+----------+
-----------+-------+-------------+---------+---------+--------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------+--------+--
---------+--------+------------+------------+
| 10 | 2 | 4 | 0 | 希望光伏企业挺过2个月 | |
| 0 | | | | 希望企业挺过两个月。 | |
1 | 0 | 1371524848 | 1371525226 |
+----+-------------+---------+--------+-----------------------------+----------+
-----------+-------+-------------+---------+---------+--------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------+--------+--
---------+--------+------------+------------+
1 row in set (0.00 sec)
mysql> explain select * from article where title='希望光伏企业挺过2个月';
+----+-------------+---------+------+---------------+------+---------+------+---
---+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | ro
ws | Extra |
+----+-------------+---------+------+---------------+------+---------+------+---
---+-------------+
| 1 | SIMPLE | article | ALL | NULL | NULL | NULL | NULL | 5
67 | Using where |
+----+-------------+---------+------+---------------+------+---------+------+---
---+-------------+
1 row in set (0.00 sec)
大部门的开发人员会认为第一种查询时,不会用到索引
本文出自 “Linux运维” 博客,请务必保留此出处http://2853725.blog.51cto.com/2843725/1562343
相关文章推荐
- Oracle的SQL语句执行效率问题查找与解决方法
- oracle的SQL语句执行效率问题查找与解决方法
- Oracle的SQL语句执行效率问题查找与解决方法
- Oracle执行计划 SQL语句执行效率问题查找与解决方法
- Oracle中SQL语句执行效率问题的查找与解决
- Oracle中SQL语句执行效率的查找与解决
- 转载:Oracle中SQL语句执行效率的查找与解决
- Oracle中SQL语句执行效率的查找与解决
- Oracle中SQL语句执行效率的查找与解决
- Oracle中SQL语句执行效率的查找与解决
- 使用 Hibernate 在 JPA 中 调用 generateSchema 会出现执行两次 SQL 语句问题的解决方法
- 执行SQL语句时出现问题操作必须使用一个可更新的查询错误的解决方法
- 关于执行Oracle下Sql语句中遇到的特殊字符问题解决办法。
- "执行SQL语句时出现问题操作必须使用一个可更新的查询"错误的解决方法
- SQL语句执行效率的查找与解决
- 使用 Navicat for MySQL 执行 SQL 语句时,出现 out of memory 问题的解决方法
- 常用优化sql语句执行效率的方法
- pl/sql developer 连接64位oracle的问题与解决方法
- 简述项目中优化sql语句执行效率的方法,从哪些方面,sql语句性能如何分析?
- sql语句用'in'执行多条语句时候,执行错误的解决方法