On 6/3/07, David Krings <[EMAIL PROTECTED]> wrote:

David Krings wrote:
> Hi!
>
> Which one is faster: PHP array_unique or SQL DISTINCT ?
>

OK, while I still like to know what the answer is, the DISTINCT wasn't
the culprit, but the way I join the tables. I ran the query across only
two tables and with that got millions of records when I expected only a
few hundred.
I guess it is time to learn some more SQL and not just go for broke and
run queries without knowing what they really do. Worked fine in the test
system with only a dozen records in each table. My approach apparently
doesn't scale well.

David


The key to speedy SQL is in the indexes. Without an index the SQL engine
iterates over every row. With an index it automagically grabs the correct
value.

Try using EXPLAIN to check your queries if they don't seem to be working as
expected.

EXPLAIN SELECT * FROM table_name;
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to