Home > database >  The index, the SQL is OR why would leave?
The index, the SQL is OR why would leave?

Time:10-15


 EXPLAIN 
SELECT * FROM
T_basic_setting_production_cp WHERE group_id=100 AND ((modify_time='2020-04-02 19:35:58. 786' AND production_cp_id & gt; 86091)
OR (modify_time & gt; 'the 2020-04-02 19:35:58. 786'))
The ORDER BY
Modify_time,
Production_cp_id ASC LIMIT 0, 10


==========================================================
Modify_time index, here is a explian results:
1 SIMPLE t_basic_setting_production_cp range PRIMARY, m_time m_time 16 54409 10.00 Using index condition; Using the where


==========================================================
 CREATE TABLE ` t_basic_setting_production_cp ` (
` production_cp_id ` bigint (20) NOT NULL AUTO_INCREMENT COMMENT 'production enterprise id,
` group_id ` bigint (20) NOT NULL COMMENT 'group coding,
` production_cp_code ` varchar (60) COLLATE utf8mb4_bin NOT NULL COMMENT 'production enterprise code,
` production_cp_name ` varchar (60) COLLATE utf8mb4_bin NOT NULL COMMENT 'production enterprise name,
` production_cp_abc ` varchar (60) COLLATE utf8mb4_bin NOT NULL COMMENT 'production enterprise mnemonics,
` is_enable ` tinyint (2) NOT NULL COMMENT 'whether to enable'
` contact ` varchar (60) COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'contacts',
` contact_type ` varchar (500) COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'contact way,
` address ` varchar (100) COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'address'
` the create_user ` bigint (20) DEFAULT NULL COMMENT 'founder,
` create_time ` datetime DEFAULT NULL COMMENT 'creation time,
` modify_user ` bigint (20) DEFAULT NULL COMMENT 'final modifier,
` modify_time ` datetime (3) the DEFAULT CURRENT_TIMESTAMP (3) ON the UPDATE CURRENT_TIMESTAMP (3) the COMMENT 'final modification time,
PRIMARY KEY (` production_cp_id `) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=195759 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='table production enterprises;

CodePudding user response:

May be go the Order By the index

CodePudding user response:

One, two or conditions, the use of a field;
2, the building of the create table statement, didn't find modify_time index on the column,
  • Related