djtozz Posted November 6, 2009 Share Posted November 6, 2009 Hi, First I would like to say that php is pretty new for me.. so please don't shoot me if this should be a stupid question! But I'm a little surpized due to following.. I have a search script (very large mysql db) which is working pretty fast for searching! I'm using following querry: $q="SELECT `url`,`caption`, `type`,`fsize`, MATCH (caption) AGAINST ('$kwd2') as score,`source`, `lastcheck`, `dateadded`, `desc`, `media`, `filename`, `sname`, `rating`, `stream`, `id` FROM `v2links` WHERE MATCH (caption) AGAINST ('$kwd2')$stype $fxtype $fxmedia $fsort LIMIT $start,$search_count"; sample: http://www.filemirrors.info Now I would like to display the 30 latest records using following querry: $q="SELECT `url`,`caption`, `type`, `id`,`fsize`,`source`, `lastcheck`, `dateadded`, `desc`, `media`, `filename`, `sname`, `rating`, `stream`, `id` FROM `v2links` Where checked=1 $stype $fxtype $fxmedia $fsort LIMIT 30"; sample: http://www.filemirrors.info/latest.html Now it seems to take much more time (3x) to display the last 30 records then when using the searchbox and enter a keyword... I thought a simple select should be going faster then match against a keyword? Is there an explenation for this or am I missing something? Thanks, Quote Link to comment https://forums.phpfreaks.com/topic/180555-solved-select-question/ Share on other sites More sharing options...
JonnoTheDev Posted November 6, 2009 Share Posted November 6, 2009 INDEXES Also what is contained in the following variables? $stype $fxtype $fxmedia $fsort Quote Link to comment https://forums.phpfreaks.com/topic/180555-solved-select-question/#findComment-952648 Share on other sites More sharing options...
djtozz Posted November 6, 2009 Author Share Posted November 6, 2009 INDEXES Also what is contained in the following variables? Thanks for your feedback, I'm not sure what you mean with indexes.. Those variables have following value $stype=" AND `fsize`<>''"; $fxmedia="AND media='avi'"; $fsort="ORDER by `lastcheck` ASC"; $fxtype is empty. Quote Link to comment https://forums.phpfreaks.com/topic/180555-solved-select-question/#findComment-952665 Share on other sites More sharing options...
JonnoTheDev Posted November 7, 2009 Share Posted November 7, 2009 Add indexes to the following fields: checked, fsize, media Make sure you are using the most efficient data types for your fields. http://www.databasejournal.com/features/mysql/article.php/1382791/Optimizing-MySQL-Queries-and-Indexes.htm Quote Link to comment https://forums.phpfreaks.com/topic/180555-solved-select-question/#findComment-953105 Share on other sites More sharing options...
djtozz Posted November 10, 2009 Author Share Posted November 10, 2009 Add indexes, Make sure you are using the most efficient data types for your fields. http://www.databasejournal.com/features/mysql/article.php/1382791/Optimizing-MySQL-Queries-and-Indexes.htm Thanks a bunch for this excellent info! Excactly what I was looking for. Quote Link to comment https://forums.phpfreaks.com/topic/180555-solved-select-question/#findComment-954678 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.