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 Stata 面板数据模型选择
    • ¥20 idea运行测试代码报错问题
    • ¥15 网络监控:网络故障告警通知
    • ¥15 django项目运行报编码错误
    • ¥15 请问这个是什么意思?
    • ¥15 STM32驱动继电器
    • ¥15 Windows server update services
    • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
    • ¥15 模糊pid与pid仿真结果几乎一样
    • ¥15 java的GUI的运用