chantown Posted December 18, 2007 Share Posted December 18, 2007 Hi, I have read that indexing will make your queries faster, but it requires more hard drive space. What exactly is it , and how should I do it for my situation? I am building a forum much like SMF. Usually I am selecting many things, so much of my queries are SELECT * FROM ...where topic_id = ... stuff like that Since I am selecting * all the time (all the columns I need to select), should I index EVERY column? Do I index the stuff being DRAWN or the stuff being SEARCHED? Like, how do I determine what to index or what not to index many thanks! Link to comment https://forums.phpfreaks.com/topic/82130-what-exactly-is-indexing/ Share on other sites More sharing options...
btherl Posted December 18, 2007 Share Posted December 18, 2007 It's not a simple question. But in general, you should index at least one column from the "WHERE" conditions of your queries. For example, if you are always searching "where topic_id = ...", then you will very likely get a more efficient system by creating an index on topic_id. In nearly all cases, you should index the stuff SEARCHED. But in some rare cases you can in fact benefit from indexing the stuff DRAWN. I would not worry about that yet though. To find if you need an index or not, try timing your queries. If the query is looking slow, take a look at the "where" clause and consider what index would narrow down the possible values enough to make the query fast. Link to comment https://forums.phpfreaks.com/topic/82130-what-exactly-is-indexing/#findComment-417442 Share on other sites More sharing options...
chantown Posted December 18, 2007 Author Share Posted December 18, 2007 When I refresh a page to get the updated stuff on my forum (time of posts, usernames, topic titles), I find that when i use "top" in my Linux, the MYSQL Process uses 3.9% of CPU power. Is this normal? And will it decrease when I index? (I have a pentium D 3.0 Dual core 4 GB ram) Link to comment https://forums.phpfreaks.com/topic/82130-what-exactly-is-indexing/#findComment-417699 Share on other sites More sharing options...
fenway Posted December 18, 2007 Share Posted December 18, 2007 Forgot about top... use mysql's internal performance indicators. Link to comment https://forums.phpfreaks.com/topic/82130-what-exactly-is-indexing/#findComment-417809 Share on other sites More sharing options...
chantown Posted December 19, 2007 Author Share Posted December 19, 2007 wats that? Link to comment https://forums.phpfreaks.com/topic/82130-what-exactly-is-indexing/#findComment-418264 Share on other sites More sharing options...
fenway Posted December 19, 2007 Share Posted December 19, 2007 Read the stickies on optimization. Link to comment https://forums.phpfreaks.com/topic/82130-what-exactly-is-indexing/#findComment-418948 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.