Re: How to filter queries using PHP

From: Terence (tk.lists_at_fastmail.fm)
Date: 11/04/03


Date: Tue, 04 Nov 2003 10:34:06 +1100
To: Phil Powell <soazine@erols.com>

Phil Powell wrote:

> I cannot honestly think of simple solutions to anything. I'm dead serious,
> I never saw that solution at all!

Phil, that is a "shocker" ;)
... we all have 'em ...

>>SELECT table1.this, table2.that
>> FROM table1 LEFT JOIN table2 ON table1.iref = table2.iref
>> WHERE table1.somefield = 'SomeValue';

If this query is heavily used or has a lot of data, make sure you create
indexes on "both" columns in the join (one from each table). If you
created one as the primary key, then it should already have a UNIQUE
index automatically created for it. You also want to index the column
you're filtering on ie. "table1.somefield" as per above example. If you
plan on using an ORDER BY clause, then create an index that spans the
columns in the order-by list (if they are from the same table).

Too many indexes impact on your INSERT performance, but I'm guessing
that you are doing a lot of reading. Database optimisation is probably a
black art, I don't know that much about it, but I think the above should
be good advice. Too many indexes are bad for other reasons to but I
forgotten them presently :)
Any experts out there with some DB optimisation advice???

good luck Phil.



Relevant Pages

  • Re: display adpter
    ... and I really don't like to be harsh and in Andrew E.'s case ... | his posts is that in many cases if the OP followed his advice they ... Yeah, I went thru some of his other posts, and you are exactly right. ... Phil Weldon ...
    (microsoft.public.windowsxp.basics)
  • Re: what to tell phyllis
    ... Phil S. wrote: ... I taught myself how to play the guitar after years in athletics and a military school, bad city neighborhoods and racial violence. ... Stick your continuous bitch advice about me in your turd cutter. ... Perhaps you and stalky ought to form two man jerk circle and roshambo for the pivot man honors. ...
    (alt.guitar.amps)
  • Re: How to filter queries using PHP
    ... Phil, that is a "shocker";) ... If this query is heavily used or has a lot of data, ... Any experts out there with some DB optimisation advice??? ...
    (alt.php)
  • Re: baffle making -- cutting the hole? http://www.holepro.com/
    ... Phil S wrote: ... http://www.holepro.com/xcart4017/xcart/home.php up to 17" holes. ... It's a tried and true method. ... offered good advice by various folks; ...
    (alt.guitar.amps)
  • Re: Removing "Messenger popup" ads
    ... "Phil" a écrit dans le message de ... > Does anyone have advice as to get rid of ...
    (microsoft.public.security)