NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
join? (Score:1)
How fast is
SELECT authname FROM invoices i WHERE i.affid = 654248 AND i.commpaid = 0;You're doing a full table scan on invoices alone, without the join, and that SHOULD be painful.
So, index on affid.
Reply to This
Re: (Score:2)
Bingo! That reduces the query time down to .15 seconds :)
I don't understand the EXPLAIN output as well as I should (duh!). How did you deduce the full table scan on invoice from this?
Re: (Score:1)
Re: (Score:2)
Ilya Martynov (http://martynov.org/ [martynov.org])
Re: (Score:2)
Ilya Martynov (http://martynov.org/ [martynov.org])
Re: (Score:1)
With the original setup, there was a key (and therefore likely an index) on b.desctype, limiting the need for a full tablescan on bills down to "just" half the table. Which turns out to be slightly less work than a full table scan on invoices. So now it has a (long) list of invoice id's it can use the primary key index on invoices to find.
Adding the index on affid, makes it a LOT cheaper to use that than either the full or
Re: (Score:1)
By about an order of magnitude.
The actual figure is highly hardware dependent, but should generally be in the range 5-10%.
Cheers,
Ben