[nycphp-talk] Adding indexes
anoland at indigente.net
Mon Mar 22 12:17:39 EDT 2010
In addition to what others said...
There is a lot more instruction both online and offline, but here is a brief
example illustrating EXPLAIN:
The docs can be a bit dense if you're not familiar with what you are looking
for, but here it is for reference:
The first things you need to look at are the `type` and `ref`s columns. They
will tell you what, if any, keys are used. Another thing to look for is any
comments in the `Extra` column. If that has NULL, or 'filesort', or 'full
scan' then you have some work to do.
I took a glance at the slides in this page and they look informative, but I
haven't watched the presentation. I will need to d/l it and watch it later.
On Mon, Mar 22, 2010 at 10:27 AM, Rob Marscher
<rmarscher at beaffinitive.com>wrote:
> On Mar 22, 2010, at 11:00 AM, Nicholas Hart wrote:
> > I am looking to analyze and speed up some of my queries by adding any
> necessary indexes. Is there a formula to follow in adding indexes to
> multiple join queries? I have made some attempts using explain but am not
> sure I understand it all that well.
> > For example:
> > $sql = "select dt1.*, d.* from
> > driver d join
> > (select `driver`, date(`leave`), sum(`points`) as pnts,
> > sum(`xpnts`) as xpnts from check_head
> > where date(`leave`) = '".$sdate."'
> > group by `driver`) dt1
> > on dt1.driver = d.id_num where `store` = '".$userStore."' ";
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the talk