user150209
user150209

Reputation:

Multi Criteria Search Algorithm

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.

Upvotes: 1

Views: 2728

Answers (2)

nont
nont

Reputation: 9519

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.

Upvotes: 1

nont
nont

Reputation: 9519

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.

Upvotes: 0

Related Questions