dpb42021 2019-04-05 08:14
浏览 243

不使用EXPLAIN不能使用FORCE INDEX

I'm working with MySQL Server version: 5.7.21.

I have a table with 2.804.806 rows, so it gets slow when I query through it without indexing.

I have a PRIMARY index on 'id' which is AUTO_INCREMENT.

EXPLAIN without using USE INDEX or FORCE

My next step was to do modify my query like this :

SELECT id, ut_date, servo_on, running_on, arc_on, robot_id FROM process__status_timers USE INDEX (id) WHERE id >934173 AND ut_date > 1546297200000 ORDER BY robot_id , id ASC

But still it was not using my key so I used FORCE INDEX and finally i got : EXPLAIN USING FORCE

But when I remove the EXPLAIN I get a syntax error:

SELECT id, ut_date, servo_on, running_on, arc_on, robot_id FROM process__status_timers FORCE INDEX (PRIMARY) WHERE id >934173 AND ut_date > 1546297200000 ORDER BY robot_id , id ASC ; 
  1. Unrecognized keyword. (near FORCE)

  2. Unrecognized keyword.(near INDEX)

  3. Unexpected token (near ()

  4. Unrecognized keyword.(near PRIMARY)

  5. Unexpected token (near ()

what I'm doing wrong ?

Thanks in advance

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)
    • ¥15 keil里为什么main.c定义的函数在it.c调用不了
    • ¥50 切换TabTip键盘的输入法
    • ¥15 可否在不同线程中调用封装数据库操作的类