<pre name="code" class="html">mysql> desc ProductInfo;
+----------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+---------+-------+
| sn | int(11) | NO | PRI | NULL | |
| productIntro | text | NO | | NULL | |
| borrowerInfo | text | NO | | NULL | |
| realBorrower | varchar(128) | YES | | NULL | |
| capitalPurpose | text | NO | | NULL | |
| repaySource | text | NO | | NULL | |
| riskInfo | text | NO | | NULL | |
| safeguard | varchar(50) | NO | | | |
| contractSn | int(11) | YES | | NULL | |
| delegator | int(11) | NO | | NULL | |
| custody | varchar(125) | NO | | | |
| riskLevel | char(1) | NO | | NULL | |
+----------------+--------------+------+-----+---------+-------+
12 rows in set (0.00 sec) mysql> show index from ProductIno;
ERROR 1146 (42S02): Table 'zjzc.ProductIno' doesn't exist
mysql> show index from ProductInfo;
+-------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| ProductInfo | 0 | PRIMARY | 1 | sn | A | 283 | NULL | NULL | | BTREE | | |
+-------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
1 row in set (0.01 sec) mysql> select sn,contractSn from ProductInfo where contractSn=45;
+-----+------------+
| sn | contractSn |
+-----+------------+
| 58 | 45 |
| 301 | 45 |
+-----+------------+
2 rows in set (0.00 sec) mysql> explain update ProductInfo set contractSn=99 where contractSn=45;
+----+-------------+-------------+-------+---------------+---------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------------+-------+---------------+---------+---------+------+------+-------------+
| 1 | SIMPLE | ProductInfo | index | NULL | PRIMARY | 4 | NULL | 283 | Using where |
+----+-------------+-------------+-------+---------------+---------+---------+------+------+-------------+
1 row in set (0.07 sec) mysql> create index ProductInfo_idx1 on ProductInfo(contractSn);
Query OK, 0 rows affected (0.23 sec)
Records: 0 Duplicates: 0 Warnings: 0 mysql> explain update ProductInfo set contractSn=99 where contractSn=45;
+----+-------------+-------------+-------+------------------+------------------+---------+-------+------+------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------------+-------+------------------+------------------+---------+-------+------+------------------------------+
| 1 | SIMPLE | ProductInfo | range | ProductInfo_idx1 | ProductInfo_idx1 | 5 | const | 2 | Using where; Using temporary |
+----+-------------+-------------+-------+------------------+------------------+---------+-------+------+------------------------------+
1 row in set (0.00 sec) /***************************************************************************************************8 mysql> show create table test100\G;
*************************** 1. row ***************************
Table: test100
Create Table: CREATE TABLE `test100` (
`sn` int(11) NOT NULL COMMENT 'product sn',
`productIntro` text NOT NULL COMMENT '产品介绍',
`borrowerInfo` text NOT NULL COMMENT '借款方信息',
`realBorrower` varchar(128) DEFAULT NULL COMMENT '实际借款人',
`capitalPurpose` text NOT NULL COMMENT '资金用途',
`repaySource` text NOT NULL COMMENT '还款来源',
`riskInfo` text NOT NULL COMMENT '风控信息',
`safeguard` varchar(50) NOT NULL DEFAULT '' COMMENT '保障信息代码列表,格式1,2,3,4',
`contractSn` int(11) DEFAULT NULL COMMENT '合同模版',
`delegator` int(11) NOT NULL COMMENT '产品委托人',
`custody` varchar(125) NOT NULL DEFAULT '' COMMENT '产品管理人',
`riskLevel` char(1) NOT NULL COMMENT '风险级别'
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec) ERROR:
No query specified mysql> show index from test100;
Empty set (0.00 sec) mysql> explain update test100 set contractSn=99 where contractSn=45;
+----+-------------+---------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+---------+------+---------------+------+---------+------+------+-------------+
| 1 | SIMPLE | test100 | ALL | NULL | NULL | NULL | NULL | 283 | Using where |
+----+-------------+---------+------+---------------+------+---------+------+------+-------------+
1 row in set (0.00 sec) mysql> create index test100_idx1 on test100(contractSn);
Query OK, 0 rows affected (0.36 sec)
Records: 0 Duplicates: 0 Warnings: 0 mysql> explain update test100 set contractSn=99 where contractSn=45;
+----+-------------+---------+-------+---------------+--------------+---------+-------+------+------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+---------+-------+---------------+--------------+---------+-------+------+------------------------------+
| 1 | SIMPLE | test100 | range | test100_idx1 | test100_idx1 | 5 | const | 2 | Using where; Using temporary |
+----+-------------+---------+-------+---------------+--------------+---------+-------+------+------------------------------+
1 row in set (0.03 sec)
												

mysql update 有无索引对比的更多相关文章

  1. MySQL和Lucene索引对比分析

    MySQL和Lucene都可以对数据构建索引并通过索引查询数据,一个是关系型数据库,一个是构建搜索引擎(Solr.ElasticSearch)的核心类库.两者的索引(index)有什么区别呢?以前写过 ...

  2. Mysql update 索引

    执行mysql update,或者delete的时候会遇到: You can't specify target table for update in FROM clause 相关的原因自不必说:下面 ...

  3. Mysql数据库的索引原理

    写在前面:索引对查询的速度有着至关重要的影响,理解索引也是进行数据库性能调优的起点.考虑如下情况,假设数据库中一个表有10^6条记录,DBMS的页面大小为4K,并存储100条记录.如果没有索引,查询将 ...

  4. Mysql 和 Postgresql(PGSQL) 对比

    Mysql 和 Postgresql(PGSQL) 对比 转载自:http://www.oschina.net/question/96003_13994 PostgreSQL与MySQL比较 MySQ ...

  5. 【Mysql优化】索引优化策略

    1:索引类型 1.1 B-tree索引 注: 名叫btree索引,大的方面看,都用的平衡树,但具体的实现上, 各引擎稍有不同, 比如,严格的说,NDB引擎,使用的是T-tree   Myisam,in ...

  6. 千万级MySQL数据库建立索引,提高性能的秘诀

    实践中如何优化MySQL 实践中,MySQL的优化主要涉及SQL语句及索引的优化.数据表结构的优化.系统配置的优化和硬件的优化四个方面,如下图所示: SQL语句及索引的优化 SQL语句的优化 SQL语 ...

  7. 阿里面试:MySQL如何设计索引更高效?

    有情怀,有干货,微信搜索[三太子敖丙]关注这个不一样的程序员. 本文 GitHub https://github.com/JavaFamily 已收录,有一线大厂面试完整考点.资料以及我的系列文章. ...

  8. mysql 高级和 索引优化,目的:查的好,查的快,性能好

    1-事物隔离级别: 更新丢失, 并发情况下,对同一字段进行更新,就会出现更新丢失,采用乐观锁,比较版本号或时间戳可解决 读未提交 解决了更新丢失但是会引起脏读, 二个session.sessionA中 ...

  9. MySQL引擎、索引和优化(li)

    一.存储引擎 存储引擎,MySQL中的数据用各种不同的技术存储在文件(或者内存)中.这些技术中的每一种技术都使用不同的存储机制.索引技巧.锁定水平并且最终提供广泛的不同的功能和能力.通过选择不同的技术 ...

随机推荐

  1. JAVA实现AES的加密和解密算法

    原文 JAVA实现AES的加密和解密算法 import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import ja ...

  2. shell中exec解析(转)

    参考:<linux命令.编辑器与shell编程> <unix环境高级编程> exec和source都属于bash内部命令(builtins commands),在bash下输入 ...

  3. c语言数组初始化问题

    2147483648字符数组的初始化,最容易理解的方式就是逐个字符赋给数组中各元素. charstr[10]={'I','','a','m','',‘h’,'a','p','p','y'}; 即把10 ...

  4. 关于运行robotium提示连接不上jar问题

    robotium运行测试helloworld报错: java.lang.NoClassDefFoundError: com.jayway.android.robotium.solo.Solo at c ...

  5. 为开发用途mac电脑瘦身

    本文介绍的瘦身方法仅仅针对开发用途的mac电脑,在我们的开发过程中会发现随着编译的程序过多非常导致硬盘空间的占用率不断上升. 原文地址:http://blog.csdn.net/qqmcy/artic ...

  6. Android4.2以及最新SDK的尝鲜使用

    谷歌已经公布了Android4.2,而且也对应的更新了SDK到4.2.事实上最基本的是谷歌这次帮开发人员把eclipse.ADT.SDK整合 到了一起,我们仅仅须要下载一个ADT Boundle,就能 ...

  7. c语言,enum

    在设置错误代号时,使用enum比宏更好看. #include <stdio.h> typedef enum { retOK = 0, errComInterruption = 0x1000 ...

  8. Python基础入门教程

    Python基础入门教程 Python基础教程 Python 简介 Python环境搭建 Python 基础语法 Python 变量类型 Python 运算符 Python 条件语句 Python 循 ...

  9. redisTemplate 操作

    redisDao封装类-其他dao集成他 package com.ffcs.wlan.dao.common; import javax.annotation.Resource; import org. ...

  10. Server-side Sessions with Redis | Flask (A Python Microframework)

    Server-side Sessions with Redis | Flask (A Python Microframework) Server-side Sessions with Redis By ...