views:

309

answers:

2

Hello,

Here's the problem : I've got a huuge (well at my level) mysql database with technical products in it. I ve got something like 150k rows of products in my database plus 10 to 20 others tables with the same amount of rows. Each tables contains a lot of criteria. Some of the criteria are text values, some are decimal, some are just boolean. I would like to provide a web access (php) to this database with filters on each criteria but I dont know how to do that really fast. I started to create a big table with all colums merged to avoid multiple join, it's cool, faster than the big join but still very very slow. Putting an index on all criteria, doesnt improve things (and i heard it was a bad idea). I was wondering if there were some cool algorithms that could help me preprocess the multi criteria search. Any idea ?

Thanks ahead.

A: 

Try Full Text Search You might want to try globbing your text fields together and doing full text search.

Optimize Your Queries For the other columns, rank them in order of how frequently you expect them to be used. Write a test suite of queries, and run them all to get a sense of the performance. Then start adding indexes, and see how it affects performance. Keep adding indexes while the performance gets better. Stop when it gets worse.

Use Explain Plan Since you didn't provide your SQL or table layout, I can't be more specific. But use the Explain Plan command to make sure your queries are hitting indexes, rather than doing table scans. This can be tricky since subtle stuff like the order of the columns in the query can affect whether or not an index is operative.

nont
Thanks for the answer. I tried a lot of things with query optimization but I'm beggining to think that sqlquerying a table directly with my filters is not part of the solution. I mean, my sql queries looks really really heavy, lots of conditions, lots of criterias. Also doing full text search means you know the value you're looking for, but i'm playing with filters : criteria are value within range, not exact value. BTW my products are mechanical precision items (gears, screw, bolt, etc.).
Logofreestyle
+1  A: 

If you're frustrated trying to do this in SQL, you could take a look at Lucene. It lets you do range searches, full text, etc.

nont