For future diagnostics : it would help a lot if people would includ an 'Explain Plan' output whenever there are database performance issues on certain queries. For Mysql just do a 'EXPLAIN select foobar from tableBar a, tableFoo b where a.foo=b.bar' and it will tell you how the mysql optimizer handles this query.
From what you've told us it looks like mysql is ignoring the indexes :
- make sure you choose your 'driving' table correctly, if you want to group all the ratings per item then your itemtable will be driving the query. (and thus put 'select blah from itemtable, ratingtable where...' instead of 'select blah from ratingtable, itemtable where...'
- looking at the mysql docs: 'MySQL can't (yet) use indexes on columns efficiently if they are declared differently' ie make sure you've declared your join columns in the same way, don't declare one as a char(10) and the other as a char(15)
- you can tell the optimizer to use an index by using hints on which index to use. Mysql docs have all the info on that as well.
Jorg
"Do or do not, there is no try" -- Yoda
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.