- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
你好,这个查询正在生成这个解释,考虑到我为两列都设置了索引,这很奇怪
'1', 'SIMPLE', 'vtr_video_transactions', 'ALL', 'user_standard,user_date', NULL, NULL, NULL, '5', 'Using where; Using filesort'
CREATE TABLE `vtr_video_transactions` (
`vtr_id` int(11) NOT NULL AUTO_INCREMENT,
`vtr_transaction_id` int(11) unsigned DEFAULT NULL,
`vtr_user_id` int(11) unsigned DEFAULT NULL,
`vtr_standards_id` int(11) unsigned DEFAULT NULL,
`vtr_video_date` datetime DEFAULT NULL,
PRIMARY KEY (`vtr_id`),
KEY `user_standard` (`vtr_user_id`,`vtr_standards_id`),
KEY `user_date` (`vtr_user_id`,`vtr_video_date`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
索引见 user_date。我在 MYSQL Workbench 上将其设置为 DESC。但是我得到了解释的文件排序。不知道为什么。干杯
表格数据
LOCK TABLES `vtr_video_transactions` WRITE;
/*!40000 ALTER TABLE `vtr_video_transactions` DISABLE KEYS */;
INSERT INTO `vtr_video_transactions` VALUES (1,1,1,2,'2015-09-05 17:18:59'),(2,2,1,3,'2015-08-27 19:04:12'),(3,2,1,4,'2015-08-27 18:55:53'),(4,10,1,119,'2015-08-27 19:04:12'),(5,11,1,10,'2015-08-27 19:04:12');
最佳答案
参见手册页 here
Indexes are less important for queries on small tables, or big tables where report queries process most or all of the rows. When a query needs to access most of the rows, reading sequentially is faster than working through an index. Sequential reads minimize disk seeks, even if not all the rows are needed for the query.
关于MYSQL - 使用 where 和 filesort,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32445032/
我有一个类似于以下内容的查询: SELECT * FROM tablename WHERE condition = 1 ORDER BY id LIMIT 1000; id是主键。我有一个索引 con
我有一些推荐表 CREATE TABLE IF NOT EXISTS `testimonials` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title
我有以下查询: SELECT * FROM shop_user_member_spots WHERE delete_flag = 0 ORDER BY date_spotte
我正在尝试创建一个选择查询,但是当我使用解释查询时,mysql 总是额外使用“使用文件排序”。 我尝试了最简单的查询,但问题并没有消失。我的表“Partidas”的结构是: CREATE TABLE
我有一个包含日期时间列的表,我按该列进行排序。无论我做什么,我总是从 EXPLAIN 中得到“使用哪里;使用文件排序”。 有没有办法让日期时间列上的 ORDER BY 不使用文件排序? 查询非常简单,
我在我的 Mysql 数据库上运行了一个 sql 查询。我有一张包含 150 万条记录的表。我正在尝试根据项目的创建者获取最近创建的 50 个项目。 这里是查询: SELECT * FROM `ite
mysql-5.6.24-win32.1432006610 我有两个用户消息表。 TMessageBody (id, body) 存储消息正文。 TMessage (id, uid, folderId
你好,这个查询正在生成这个解释,考虑到我为两列都设置了索引,这很奇怪 '1', 'SIMPLE', 'vtr_video_transactions', 'ALL', 'user_standard,us
我有一个简单的表格-> id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY by_id INT UNSIGNED NOT NULL posted_o
我有一个像这样的表结构 comment_id primary key comment_content comment_author comment_author_url 当我像 这样触发查询时 exp
我有一个包含 40,000,000 行的表,我正在尝试优化我的查询,因为花费的时间太长。 首先,这是我的 table : 创建表 恢复 ( yearMonth char(6) DEFAULT NULL
我正在尝试优化使用 order by 子句的 sql 查询。当我使用 EXPLAIN 时,查询总是显示“使用文件排序”。我正在将此查询应用于一个群组讨论论坛,其中有用户附加到帖子的标签。 这是我正在使
我正在尝试优化此查询: SELECT `posts`.* FROM `posts` INNER JOIN `posts_tags` ON `posts`.id = `posts_tags`.
子查询1: SELECT * from big_table where category = 'fruits' and name = 'apple' order by yyyymmdd desc 解释
我有一个查询比这个查询稍微复杂一点(获得最便宜的价格),但这代表了性能问题。因此查询不能更改。 我尝试创建不同的索引来加快排序速度,但没有运气。 需要什么索引才能更快地获得这个 1.4 秒的持久查询?
我有一张带有日期时间 (DATE) 和位 (PUBLIC) 的 Cars 表。 现在我想获取按 DATE 和 PUBLIC = 1 排序的行,所以我使用: select c.* from Ca
我有如下 2 个表: CREATE TABLE `ox_campaigns` ( `
我正在尝试使用 EXPLAIN 优化此 mysql 查询。有人可以帮我解决这个问题吗? EXPLAIN SELECT * FROM keyword WHERE keyword LIKE "panaso
有表格: CREATE TABLE `deal_keyword` ( `deal_id` int(11) unsigned NOT NULL default '0', `keyword_id`
我将用这样的查询来解释自己:(post_id= PRIMARY, blog_id=index ) SELECT post_id FROM posts WHERE blog_id IN (2,3,...
我是一名优秀的程序员,十分优秀!