MySQL: Optimal index for between queries

后端 未结 5 874
南笙
南笙 2021-02-19 13:26

I have a table with the following structure:

CREATE TABLE `geo_ip` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `start_ip` int(10) unsigned NOT NULL,
  `end_ip         


        
5条回答
  •  难免孤独
    2021-02-19 14:18

    Adding indices will help.

    Note: If your query is sth like

    where x between a and b AND y between c and d
    

    , a INDEX(x, y) will not improve the performance, but two seperate indices for x and y will.

提交回复
热议问题