benphp Posted June 7, 2008 Share Posted June 7, 2008 I have a search query that searches longtext for search terms, and the queries are starting to bog down. Would it help to index a text field that can contain 5000 chars or more? Thanks! Link to comment https://forums.phpfreaks.com/topic/109184-does-indexing-a-longtext-field-help-with-text-searches/ Share on other sites More sharing options...
benphp Posted June 7, 2008 Author Share Posted June 7, 2008 While I was waiting, I did some testing. OMYGOD what have I been missing? For anyone who hasn't done this, index your long text tables so: ALTER TABLE `tablename` ADD FULLTEXT (textfield1); ALTER TABLE `tablename` ADD FULLTEXT (textfield2); then change your select statements from WHERE textfield1 LIKE '%$term%' to WHERE MATCH (textfield1) AGAINST ('$term') What a difference! Link to comment https://forums.phpfreaks.com/topic/109184-does-indexing-a-longtext-field-help-with-text-searches/#findComment-560100 Share on other sites More sharing options...
benphp Posted June 7, 2008 Author Share Posted June 7, 2008 Okay, so can someone tell me why it's not a good idea to index everything? Link to comment https://forums.phpfreaks.com/topic/109184-does-indexing-a-longtext-field-help-with-text-searches/#findComment-560111 Share on other sites More sharing options...
fenway Posted June 10, 2008 Share Posted June 10, 2008 Okay, so can someone tell me why it's not a good idea to index everything? Because not every query can utilize every index (very true for 4.1) and it's expensive to keep it up to date. Link to comment https://forums.phpfreaks.com/topic/109184-does-indexing-a-longtext-field-help-with-text-searches/#findComment-562374 Share on other sites More sharing options...
benphp Posted June 13, 2008 Author Share Posted June 13, 2008 Expensive in storage or time? If I understand correctly, it takes a little more time to enter a new record if a table is indexed, and the index itself takes disk space. Is that what you mean by expensive? Link to comment https://forums.phpfreaks.com/topic/109184-does-indexing-a-longtext-field-help-with-text-searches/#findComment-565236 Share on other sites More sharing options...
fenway Posted June 14, 2008 Share Posted June 14, 2008 Both, but time is more important -- unless the table really grows, and then index performance drops with increasing size. Link to comment https://forums.phpfreaks.com/topic/109184-does-indexing-a-longtext-field-help-with-text-searches/#findComment-565693 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.