<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. asp.net 通过 Handler 导出数据至excel (让用户下载)

    效果图: 代码: Export2Excel.ashx <%@ WebHandler Language="C#" CodeBehind="Export2Excel.a ...

  2. Boost学习之可移植路径操作--filesystem

    Boost.Filesystem 库为对路径.文件和目录进行查询和操作提供了可移植的工具,已经被C++标准委员会接纳包含到TR2中. 编译 使用Boost.Filesystem 库之前要先编译它,请参 ...

  3. ios qq 分享 失败

    1. TencentOAuth 是需要调用,但QQ代码共享是没有解释.共享代码如下面: TencentOAuth *auth = [[TencentOAuth alloc] initWithAppId ...

  4. ADO.NET 对象 结构图

  5. 不是什么时候都可以用栈来声明对象并使用(自动释放)——Delphi里到处都是编译器魔法,并且自动帮助实例化界面元素指针

    一直都喜欢这样显示窗口,因为简单高效: void MainWidget::ShowMyWindow() { MyWidget form(this); form.resize(,); form.exec ...

  6. ARMv8 Linux内核head.S源码分析

    ARMv8Linux内核head.S主要工作内容: 1. 从el2特权级退回到el1 2. 确认处理器类型 3. 计算内核镜像的起始物理地址及物理地址与虚拟地址之间的偏移 4. 验证设备树的地址是否有 ...

  7. python算法之二分查找

    说明:大部分代码是在网上找到的,好几个代码思路总结出来的 通常写算法,习惯用C语言写,显得思路清晰.可是假设一旦把思路确定下来,并且又不想打草稿.想高速写下来看看效果,还是python写的比較快.也看 ...

  8. Spring 从零開始-05

    最终能到Spring的AOP编程了,AOP的概念特别的多.所以须要你在開始之前有点了解,然后通过代码慢慢学习! - 切面(Aspect):一个关注点的模块化,这个关注点实现可能另外横切多个对象.事务管 ...

  9. 用lambda表达式声明委托

    首先来分享一段代码: Func<int, int, int> addMethod = (int x, int y) => (x + y); 熟悉的人肯定知道这句话是什么意思,可是不熟 ...

  10. 14.18 InnoDB Backup and Recovery 备份和恢复:

    14.18 InnoDB Backup and Recovery 备份和恢复: 安全数据库管理的关键是 做定期的备份,依赖你的数据卷, MySQL server的数量和数据库的负载,你可以使用那些技术 ...