在我的数据库中我有名为fo_image_guestimage的表,它仅包含多于2,63,000行。但是,当我试图更新只有一个的内容,它yakes太多的时间(121.683ms)如何最小化在mysql中的查询时间
我的表结构 -
我的查询执行和它的时间
如何最小化mysql中的查询时间?我的表类型是InnoDB。
编辑1-
我的数据库大小 - 3.5 GB,fo_guest_image表大小2.8 GB
表结构
CREATE TABLE `fo_guest_image` (
`Fo_Image_Id` INT(10) NOT NULL AUTO_INCREMENT,
`Fo_Image_Regno` VARCHAR(10) NULL,
`Fo_Image_GuestHistoryId` INT(10) NOT NULL,
`Fo_Image_Photo` LONGBLOB NOT NULL,
`Fo_Image_Doc1` LONGBLOB NOT NULL,
`Fo_Image_Doc2` LONGBLOB NOT NULL,
`Fo_Image_Doc3` LONGBLOB NOT NULL,
`Fo_Image_Doc4` LONGBLOB NOT NULL,
`Fo_Image_Doc5` LONGBLOB NOT NULL,
`Fo_Image_Doc6` LONGBLOB NOT NULL,
`Fo_Image_Billno` VARCHAR(10) NULL,
PRIMARY KEY (`Fo_Image_Id`)
)
ENGINE=InnoDB
ROW_FORMAT=DEFAULT
AUTO_INCREMENT=36857
查询随着执行时间 -
select COUNT(Fo_Image_Regno) from fo_guest_image; Time: 11.483ms
select * from fo_guest_image where Fo_Image_Regno='G13603'; Time: 101.381ms
update fo_guest_image set Fo_Image_Regno='T13603' where Fo_Image_Regno='G13603'; Time: 144.360ms
我已经尝试了nonblob表: - fo_daybook大小400 KB
查询随着执行时间 -每天
select * from fo_daybook; Time: 0.144ms
select fo_daybok_Regno from fo_daybook; Time: 0.004ms
update fo_daybook set fo_daybok_Regno ='T13603' where fo_daybok_Regno ='G13603'; Time: 0.011ms
我的客户增加了1000行fo_guest_image。现在fo_guest_image表格大小为2.8 GB,肯定会逐日增加。如果桌子有一天达到10 G.B,我很可怕。那么演出会发生什么。
在'fo_image_GuestHistoryId'上创建索引? – hjpotter92
非BLOB列的更新需要多长时间?表中总共有多少行,而'fo_image_GuestHistoryId = 0'?这张桌子上是否有任何索引或限制? – Stoleg
@stoleg这是一个非BLOB列!我的桌子上没有索引。 fo_image_id是主键,全部都是 – Sagotharan