Multiple table search MySQL & PHP

Get help on web editors (Frontpage, Dreamweaver) and web languages (HTML, ASP, PHP).
Post Reply
DarkRanger
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

Post 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.
Image
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: Multiple table search MySQL & PHP

Post by RuadRauFlessa »

You might want to turn on Fulltext-indexing and have a read over

here
and
here
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
DarkRanger
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

Post 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
Image
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: Multiple table search MySQL & PHP

Post 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.
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
Post Reply