PDA

View Full Version : Vấn đề tìm kiếm trong MySQL



3do
19-06-2007, 11:58
Mình muốn tăng tốc độ search trong database và nó nghe nói về việc lập index, sử dụng fulltext.

Mình đã thử dùng fulltext để test thử với 2 table như sau:

testnoindex (id, content)
testindex (id, content), field content sử dụng fulltext

Mỗi table có trên 10.000 hàng, kích thước khoảng 468MB. File index của table testindex là 192MB, của testnoindex là 0.1MB.

Thực hiện câu truy vấn

select count(*) from testindex where match(content) against ('requirement' IN BOOLEAN MODE);

mất 19.31s



select count(*) from testnoindex where content like '%requirement%';

mất 14.22

Tại sao table testindex với field content là fulltext đã tạo index rồi lại search lâu hơn cả table testnoindex? Hiện giờ thì thời gian thực hiện cao truy vấn như vậy là quá lâu, có giải pháp nào để rút ngắn thời gian thực thi lại không (dưới 1s)?