two-column indexes and joins with ranges

2004-10-01 Thread William M. Shubert
I have a performance/index usage problem, and I am hoping somebody can tell me why this problem exists, and whether there is a better solution than the workaround that I'm using now. The problem: I have a table with a two column index, such as CREATE TABLE transactions ( account_id INT NOT

Re: two-column indexes and joins with ranges

2004-10-01 Thread Michael Stassen
Well, you haven't posted the output of EXPLAIN, but I'll take a guess. I expect mysql sees your query as having a JOIN condition of accounts.account_id = transactions.account_id and two WHERE conditions: WHERE accounts.name = 'dave' AND when BETWEEN '2004-02-05' AND '2004-02-10' The

Re: two-column indexes and joins with ranges

2004-10-01 Thread William M. Shubert
Thanks for the suggestion, but no luck. Here's the explain output for, in order, my original query, the 2-part query, and the explicit join (note, not quite like my first post, I had cleaned up my tables to simplify the situation): mysql explain SELECT * FROM accounts, transactions WHERE