Re: help with making appropriate indexes.
| From: | lallous | Date: | Fri, 16 Aug 2002 10:05:58 +0000 |
| Subject: | Re: help with making appropriate indexes. | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-112929@lists.php.net to get a copy of this message | ||
Thanks Miles.
But i'm not satisfied with your answer. I instinctly created indexes on
every field that I'm using w/ conditions.
But I feel that my script can be rewritten more efficiently using JOINTs or
other things.
Any site with reading material regarding how to index and make complex
queries fast?
I use the 'table_' just to hide the original table names prefixes.
Elias
"Miles Thompson" <milesthompson@ns.sympatico.ca> wrote in message
news:5.0.2.1.0.20020815112945.018d8690@pop1.ns.sympatico.ca...
> General rule of thumb - create indexes on any fields which will be used in
> the conditional part of a select statement, whether where or join. Since
> you are working with tables, you can save yourself a lot of typing by
> dropping the "table_" from the table names. After all, that's what they
> are. (You can do this unless you've gone too far with your system.)
>
> Miles Thompson
>
> At 02:15 PM 8/14/2002 +0200, lallous wrote:
> >give this query:
> >
> > SELECT
> > table_routing.id AS routeid,
> > table_pricing.units AS price,
> > table_routing.provider AS providerid,
> > table_country.name AS countryname,
> > table_country.id AS countrycode
> > FROM
> > table_pricing,
> > table_routing,
> > table_country
> > WHERE
> > table_country.id = table_routing.country
> > AND
> > table_routing.country = table_pricing.country
> > AND
> > table_routing.provider = table_pricing.provider
> > AND
> > table_country.enabled = 1
> > ORDER BY routeid
> >
> >what keys / indexes should I create on whatever tables to make this query
> >efficient?
> >I don't know if this query can be re-written even with JOINs and stuff.
> >
> >Please advise,
> >
> >If you've got an online doc. about that it will help too.
> >
> >
> >Elias
> >
> >
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
>
>