1. select * from test  where a=xx group by b order by c   如何加索引

CREATE TABLE `index_test` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL DEFAULT '',
`gid` int(11) NOT NULL DEFAULT '0',
`age` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

mysql> select * from index_test;
+----+------------+-----+
| id | name | gid |
+----+------------+-----+
| 1 | taoshihan | 2 |
| 2 | taoshihan1 | 2 |
+----+------------+-----+

2. 加个联合索引试试

alter table index_test add index name_gid_age_index(name,gid,age);

explain select * from index_test where name='taoshihan' group by gid order by age;

[MySQL] 测试where group by order by的索引问题的更多相关文章

  1. MySql学习(二) —— where / having / group by / order by / limit 简单查询

    注:该MySql系列博客仅为个人学习笔记. 这篇博客主要记录sql的五种子句查询语法! 一个重要的概念:将字段当做变量看,无论是条件,还是函数,或者查出来的字段. select五种子句 where 条 ...

  2. Mysql group by,order by,dinstict优化

    1.order by优化 2.group by优化 3.Dinstinct 优化 1.order by优化 实现方式: 1. 根据索引字段排序,利用索引取出的数据已经是排好序的,直接返回给客户端: 2 ...

  3. 在mysql中使用group by和order by取每个分组中日期最大一行数据

    转载自:https://blog.csdn.net/shiyong1949/article/details/78482737 在mysql中使用group by进行分组后取某一列的最大值,我们可以直接 ...

  4. 一次 group by + order by 性能优化分析

    一次 group by + order by 性能优化分析 最近通过一个日志表做排行的时候发现特别卡,最后问题得到了解决,梳理一些索引和MySQL执行过程的经验,但是最后还是有5个谜题没解开,希望大家 ...

  5. MySQL中无GROUP BY直接HAVING的问题【转】

    本文来自网址: http://www.penglixun.com/tech/database/having_without_groupby_in_mysql.html 今天有同学给我反应,有一张表,i ...

  6. mysql distinct跟group by性能

    mysql distinct和group by性能   1,测试前的准备 //准备一张测试表 mysql> CREATE TABLE `test_test` ( ->   `id` int ...

  7. Oracle和MySQL分组查询GROUP BY

    Oracle和MySQL分组查询GROUP BY 真题1.Oracle和MySQL中的分组(GROUP BY)有什么区别? 答案:Oracle对于GROUP BY是严格的,所有要SELECT出来的字段 ...

  8. [MySQL 5.6] MySQL 5.6 group commit 性能测试及内部实现流程

    [MySQL 5.6] MySQL 5.6 group commit 性能测试及内部实现流程 http://mysqllover.com/?p=581 尽管Mariadb以及Facebook在long ...

  9. Mysql关键字之Group By(一)

    原文地址,优先更新https://hhe0.github.io group by 是一个我们在日常工作学习过程中经常遇到的一个Mysql关键字.现总结其用法如下,内容会不断补充,出现错误欢迎批评指正. ...

随机推荐

  1. unittest生产html测试报告

    需要添加HTMLTestRunner.py文件,我用的ubuntu16.04下的python3.5.2,所以我放在/usr/lib/python3.5下 import unittest import ...

  2. SQL Server 创建服务器和数据库级别审计

    一.概述 在上一篇文章中已经介绍了审计的概念:本篇文章主要介绍如何创建审计,以及该收集哪些审核规范. 二.常用的审核对象 2.1.服务器审核对象 1.FAILED_LOGIN_GROUP( Audit ...

  3. 1.6 Why only in China?

    Android plug-in is in full swing in China, why is it silent in foreign countries? The applications o ...

  4. 数组Array和列表集合ArrayList、LinkedList和Vector的区别

    一.ArrayList和Vector的区别 ArrayList与Vector主要从以下方面来说. 1.同步性: Vector是线程安全的,也就是说是同步的,而ArrayList是线程序不安全的,不是同 ...

  5. Android 音视频开发(七): 音视频录制流程总结

    在前面我们学习和使用了AudioRecord.AudioTrack.Camera.MediaExtractor.MediaMuxer API.MediaCodec. 学习和使用了上述的API之后,相信 ...

  6. [Swift]LeetCode69. x 的平方根 | Sqrt(x)

    Implement int sqrt(int x). Compute and return the square root of x, where x is guaranteed to be a no ...

  7. [Swift]LeetCode266.回文全排列 $ Palindrome Permutation

    Given a string, determine if a permutation of the string could form a palindrome. For example," ...

  8. [Swift]LeetCode929. 独特的电子邮件地址 | Unique Email Addresses

    Every email consists of a local name and a domain name, separated by the @ sign. For example, in ali ...

  9. Java基础--Eclipse使用

    Eclipse是JavaWeb开发最常用的工具,下面详细介绍一下如何下载安装最新版Eclipse.本文eclipse的使用是在JDK安装配置完成的基础上进行的,否则Eclipse安装后可能无法运行程序 ...

  10. Xapian的内存索引

    关键字:xapian.内存索引 xapian除了提供用于生产环境的磁盘索引,也提供了内存索引(InMemoryDatabase).内存索引.我们可以通过观察内存索引的设计,来了解xapian的设计思路 ...