Re: How to filter queries using PHP
From: Terence (tk.lists_at_fastmail.fm)
Date: 11/04/03
- Next message: Andy Hassall: "Re: segmentation fault at the end of script"
- Previous message: Terence: "Re: Mixing Oil and Water ?? (PHP with UML & Unit Testing)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
- Next message: Andy Hassall: "Re: segmentation fault at the end of script"
- Previous message: Terence: "Re: Mixing Oil and Water ?? (PHP with UML & Unit Testing)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|