mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 16:00:24 +08:00 
			
		
		
		
	优化edgeIPItems索引
This commit is contained in:
		@@ -416,10 +416,10 @@ func (this *IPItemDAO) ListIPItemsWithListId(tx *dbs.Tx, listId int64, sourceUse
 | 
			
		||||
// ListIPItemsAfterVersion 根据版本号查找IP列表
 | 
			
		||||
func (this *IPItemDAO) ListIPItemsAfterVersion(tx *dbs.Tx, version int64, size int64) (result []*IPItem, err error) {
 | 
			
		||||
	_, err = this.Query(tx).
 | 
			
		||||
		UseIndex("version").
 | 
			
		||||
		// 这里不要设置状态参数,因为我们要知道哪些是删除的
 | 
			
		||||
		Gt("version", version).
 | 
			
		||||
		Asc("version").
 | 
			
		||||
		Asc("id").
 | 
			
		||||
		Limit(size).
 | 
			
		||||
		Slice(&result).
 | 
			
		||||
		FindAll()
 | 
			
		||||
 
 | 
			
		||||
@@ -62184,7 +62184,7 @@
 | 
			
		||||
      "name": "edgeIPItems",
 | 
			
		||||
      "engine": "InnoDB",
 | 
			
		||||
      "charset": "utf8mb4_general_ci",
 | 
			
		||||
      "definition": "CREATE TABLE `edgeIPItems` (\n  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n  `listId` int(11) unsigned DEFAULT '0' COMMENT '所属名单ID',\n  `type` varchar(64) DEFAULT 'ipv4' COMMENT '类型',\n  `ipFrom` varchar(64) DEFAULT NULL COMMENT '开始IP',\n  `ipTo` varchar(64) DEFAULT NULL COMMENT '结束IP',\n  `ipFromLong` bigint(20) unsigned DEFAULT '0' COMMENT '开始IP整型',\n  `ipToLong` bigint(20) unsigned DEFAULT '0' COMMENT '结束IP整型',\n  `version` bigint(20) unsigned DEFAULT '0' COMMENT '版本',\n  `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n  `updatedAt` bigint(11) unsigned DEFAULT '0' COMMENT '修改时间',\n  `reason` varchar(255) DEFAULT NULL COMMENT '加入说明',\n  `eventLevel` varchar(64) DEFAULT NULL COMMENT '事件级别',\n  `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n  `expiredAt` bigint(11) unsigned DEFAULT '0' COMMENT '过期时间',\n  `serverId` int(11) unsigned DEFAULT '0' COMMENT '有效范围服务ID',\n  `nodeId` int(11) unsigned DEFAULT '0' COMMENT '有效范围节点ID',\n  `sourceNodeId` int(11) unsigned DEFAULT '0' COMMENT '来源节点ID',\n  `sourceServerId` int(11) unsigned DEFAULT '0' COMMENT '来源服务ID',\n  `sourceHTTPFirewallPolicyId` int(11) unsigned DEFAULT '0' COMMENT '来源策略ID',\n  `sourceHTTPFirewallRuleGroupId` int(11) unsigned DEFAULT '0' COMMENT '来源规则集分组ID',\n  `sourceHTTPFirewallRuleSetId` int(11) unsigned DEFAULT '0' COMMENT '来源规则集ID',\n  `sourceUserId` bigint(11) unsigned DEFAULT '0' COMMENT '用户ID',\n  `isRead` tinyint(1) unsigned DEFAULT '1' COMMENT '是否已读',\n  PRIMARY KEY (`id`),\n  KEY `listId` (`listId`),\n  KEY `version_expiredAt` (`version`,`expiredAt`) USING BTREE,\n  KEY `ipFrom` (`ipFrom`),\n  KEY `serverId` (`serverId`),\n  KEY `expiredAt_state` (`expiredAt`,`state`) USING BTREE,\n  KEY `isRead` (`expiredAt`,`isRead`) USING BTREE,\n  KEY `createdAt` (`createdAt`),\n  KEY `sourceUserId` (`sourceUserId`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='IP'",
 | 
			
		||||
      "definition": "CREATE TABLE `edgeIPItems` (\n  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n  `listId` int(11) unsigned DEFAULT '0' COMMENT '所属名单ID',\n  `type` varchar(64) DEFAULT 'ipv4' COMMENT '类型',\n  `ipFrom` varchar(64) DEFAULT NULL COMMENT '开始IP',\n  `ipTo` varchar(64) DEFAULT NULL COMMENT '结束IP',\n  `ipFromLong` bigint(20) unsigned DEFAULT '0' COMMENT '开始IP整型',\n  `ipToLong` bigint(20) unsigned DEFAULT '0' COMMENT '结束IP整型',\n  `version` bigint(20) unsigned DEFAULT '0' COMMENT '版本',\n  `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n  `updatedAt` bigint(11) unsigned DEFAULT '0' COMMENT '修改时间',\n  `reason` varchar(255) DEFAULT NULL COMMENT '加入说明',\n  `eventLevel` varchar(64) DEFAULT NULL COMMENT '事件级别',\n  `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n  `expiredAt` bigint(11) unsigned DEFAULT '0' COMMENT '过期时间',\n  `serverId` int(11) unsigned DEFAULT '0' COMMENT '有效范围服务ID',\n  `nodeId` int(11) unsigned DEFAULT '0' COMMENT '有效范围节点ID',\n  `sourceNodeId` int(11) unsigned DEFAULT '0' COMMENT '来源节点ID',\n  `sourceServerId` int(11) unsigned DEFAULT '0' COMMENT '来源服务ID',\n  `sourceHTTPFirewallPolicyId` int(11) unsigned DEFAULT '0' COMMENT '来源策略ID',\n  `sourceHTTPFirewallRuleGroupId` int(11) unsigned DEFAULT '0' COMMENT '来源规则集分组ID',\n  `sourceHTTPFirewallRuleSetId` int(11) unsigned DEFAULT '0' COMMENT '来源规则集ID',\n  `sourceUserId` bigint(11) unsigned DEFAULT '0' COMMENT '用户ID',\n  `isRead` tinyint(1) unsigned DEFAULT '1' COMMENT '是否已读',\n  PRIMARY KEY (`id`),\n  KEY `listId` (`listId`),\n  KEY `ipFrom` (`ipFrom`),\n  KEY `serverId` (`serverId`),\n  KEY `expiredAt_state` (`expiredAt`,`state`) USING BTREE,\n  KEY `isRead` (`expiredAt`,`isRead`) USING BTREE,\n  KEY `createdAt` (`createdAt`),\n  KEY `sourceUserId` (`sourceUserId`),\n  KEY `version` (`version`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='IP'",
 | 
			
		||||
      "fields": [
 | 
			
		||||
        {
 | 
			
		||||
          "name": "id",
 | 
			
		||||
@@ -62288,10 +62288,6 @@
 | 
			
		||||
          "name": "listId",
 | 
			
		||||
          "definition": "KEY `listId` (`listId`) USING BTREE"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          "name": "version_expiredAt",
 | 
			
		||||
          "definition": "KEY `version_expiredAt` (`version`,`expiredAt`) USING BTREE"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          "name": "ipFrom",
 | 
			
		||||
          "definition": "KEY `ipFrom` (`ipFrom`) USING BTREE"
 | 
			
		||||
@@ -62315,6 +62311,10 @@
 | 
			
		||||
        {
 | 
			
		||||
          "name": "sourceUserId",
 | 
			
		||||
          "definition": "KEY `sourceUserId` (`sourceUserId`) USING BTREE"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          "name": "version",
 | 
			
		||||
          "definition": "KEY `version` (`version`) USING BTREE"
 | 
			
		||||
        }
 | 
			
		||||
      ],
 | 
			
		||||
      "records": []
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user