Hi all, I have a table with about 100 records in it. Some rows contain very much data (100+ words). So the whole table contains loads of valuable rows. I also have a PHP file which selects the rows from the db. It takes about 10-12 seconds to load. This is why I thought about indexing the table. How could I do this? I know it would be a lot faster. Do I have to modify the php code as well? Any help appreciated. Thanks in advance. Best Regards, Akos
Indexing helps for a "where x = y". If you "select * from table", it won't make it faster. It also won't make it faster if you use LIKE instead of =. With 100 records, you should be able to do a "select *" in about the time it takes you to get the Enter key all the way down. You have something else slowing things down. (Some hosts have very fast hosting but very slow databases.)
i think you have a problem either with your select or with your server. a query shouldn't take that long on 100 rows, no matter how big the data is (well if you store 1gig blobs in it it might be slow due to bandwith) the best idea is to run an explain on your query (just run mysql from command line, or from mysql benchmark and put an EXPLAIN infront of your query) and check the output. if your query is doing some complicated search on the field having the large amount of text you might have to consider adding a full text index on it
A table with only 100 records should not take that long to load. And indexing such a short table will not noticeably speed things up. There is something wrong with your code that is slowing things to a crawl. Fix that problem and you won't need to index your table nor write the indexing code.
Develop cache system for your website. It's faster and safer. You're going to have data stored in 2 different places - MySQL and .HTML / .TXT. Google for - php mysql cache.