欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

mysql索引字段长度的问题_MySQL

程序员文章站 2023-12-23 20:20:27
...
今天在做某网站列表页的抓取的时候,对数据库中列表页URL字段作了唯一性约束,免得还得自己手动进行排重,结果每次当插入重复的数据的时候,就出现了问题了,错误信息如下:

java.sql.SQLException: Incorrect key file for table './dianping/dianping_list_url.MYI'; try to repair it Query: INSERT IGNORE INTO dianping_list_ur
at org.apache.commons.dbutils.AbstractQueryRunner.rethrow(AbstractQueryRunner.java:363)
at org.apache.commons.dbutils.QueryRunner.batch(QueryRunner.java:154)
at org.apache.commons.dbutils.QueryRunner.batch(QueryRunner.java:91)
at com.umsg.db.Store.batch(Store.java:41)
at com.umsg.db.Store$$EnhancerByCGLIB$$b856cba1.CGLIB$batch$0()
at com.umsg.db.Store$$EnhancerByCGLIB$$b856cba1$$FastClassByCGLIB$$82a71de6.invoke()
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at com.umsg.db.StoreProxy.intercept(StoreProxy.java:42)
at com.umsg.db.Store$$EnhancerByCGLIB$$b856cba1.batch()
at com.umsg.fetch.CrawlListPages.insertListUrls(CrawlListPages.java:268)
at com.umsg.fetch.CrawlListPages.crawl(CrawlListPages.java:236)
at com.umsg.fetch.CrawlListPages.main(CrawlListPages.java:542)

错误信息显示:表已经损坏了,因为之前我修改过表的类型,从MyISAM-->InnoDB,我以为是这块出问题了,导致表坏了,但是把表drop掉,然后重新建表也不行,反正网上介绍的各种方法都试过了,什么repair,myisamchk等命令都用过了。还是不行。

最后康老师说mysql索引的字段的长度是有限制的。网上说不能超过1000,然后把url长度修改为128,程序顺利跑了起来。

看来这个问题一定得引起注意,Mysql既然这么做,需要防止索引文件太大,导致查询速度变慢。

上一篇:

下一篇: