Multiple table search MySQL & PHP
-
- Registered User
- Posts: 8346
- Joined: 10 May 2006, 02:00
- Processor: Intel i5-3750
- Motherboard: Gigabyte
- Graphics card: nVidia GTX 550Ti
- Memory: 8GB Jetram
- Contact:
Multiple table search MySQL & PHP
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.
-
- Registered User
- Posts: 20576
- Joined: 19 Sep 2003, 02:00
- Location: Bloodbank
Re: Multiple table search MySQL & PHP
- Spoiler (show)
-
- Registered User
- Posts: 8346
- Joined: 10 May 2006, 02:00
- Processor: Intel i5-3750
- Motherboard: Gigabyte
- Graphics card: nVidia GTX 550Ti
- Memory: 8GB Jetram
- Contact:
Re: Multiple table search MySQL & PHP
Thanks. Also got a reply on php freaks.
Just to help anyone who might have the same issueQuickOldCar 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.
-
- Registered User
- Posts: 20576
- Joined: 19 Sep 2003, 02:00
- Location: Bloodbank
Re: Multiple table search MySQL & PHP
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.
- Spoiler (show)