Page 1 of 1
Multiple table search MySQL & PHP
Posted: 06 Jul 2011, 08:24
by DarkRanger
Does anybody know of some code/script for searching multiple tables/columns in one go. I wrote something, but it's 400 lines odd and with 14000 records to search, it takes way to long (20 - 30 seconds) or times out. Any help will be appreciated.
Re: Multiple table search MySQL & PHP
Posted: 06 Jul 2011, 09:11
by RuadRauFlessa
You might want to turn on Fulltext-indexing and have a read over
here
and
here
Re: Multiple table search MySQL & PHP
Posted: 06 Jul 2011, 09:47
by DarkRanger
Thanks. Also got a reply on php freaks.
QuickOldCar on phpfreaks.com wrote:I'm assuming you are using JOIN and multiple WHERE,AND,OR or possible LIKE, MATCH mysql select statements.
To speed the queries up you can create indexes on any WHERE,AND,OR values
http://dev.mysql.com/doc/refman/5.6/en/ ... index.html
You can view the slow query log to find your bottlenecks
http://dev.mysql.com/doc/refman/5.6/en/ ... y-log.html
It does matter the order in which you place these, try EXPLAIN, SHOW STATUS, and SHOW PROCESSLIST
http://dev.mysql.com/doc/refman/5.6/en/explain.html
http://dev.mysql.com/doc/refman/5.6/en/show-status.html
http://dev.mysql.com/doc/refman/5.6/en/ ... slist.html
Look into memcache to lessen the queries by caching.
http://memcached.org/
or
http://php.net/manual/en/book.memcache.php
If none of the above helps you (which they should), or to get quicker responses to queries, minimize results and only fetch data you need to.
To show the solutions can help:
http://dynaindex.com/search.php?s=%2Bli ... =on&page=1
That's a multiple search sifting through a million plus posts for the correct content in multiple columns, pages will get cached and also is on one of my home computers (single core cpu and run it hard) on a residential line. The thumbs are live loading.
Just to help anyone who might have the same issue
Re: Multiple table search MySQL & PHP
Posted: 06 Jul 2011, 10:06
by RuadRauFlessa
Ye but still a better way to do what you want is probably to use full text indexing and use a what is intended for it rather than bunching a couple of queries into joins and such.