Re: [nyphp-talk] PHP array_unique vs. SQL DISTINCT

2007-06-04 Thread David Krings
Morgan Craft wrote: If you are using DISTINCT probably means you need to normalize your data and look to join more appropriately. Also for creating indexes you really need to consider how you plan to access your data and how it will be used - which goes back to properly normalizing database ta

Re: [nyphp-talk] PHP array_unique vs. SQL DISTINCT

2007-06-04 Thread Morgan Craft
If you are using DISTINCT probably means you need to normalize your data and look to join more appropriately. Also for creating indexes you really need to consider how you plan to access your data and how it will be used - which goes back to properly normalizing database tables. With properly

Re: [nyphp-talk] PHP array_unique vs. SQL DISTINCT

2007-06-04 Thread David Krings
Adrian Noland wrote: > When it comes to choosing which columns to index, you want to pick something with a high cardinality, or, for lack of a better term, "uniqueablity". Gender wont have a high cardinality because there are only 2 choices for many records. Last name on your personal family a

Re: [nyphp-talk] PHP array_unique vs. SQL DISTINCT

2007-06-04 Thread Adrian Noland
On 6/3/07, David Krings <[EMAIL PROTECTED]> wrote: Adrian Noland wrote: > 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. This is really an eyeopener. After indexing all those columns t

Re: [nyphp-talk] PHP array_unique vs. SQL DISTINCT

2007-06-03 Thread David Krings
Adrian Noland wrote: 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. This is really an eyeopener. After indexing all those columns that come up in some selects running the same query that

Re: [nyphp-talk] PHP array_unique vs. SQL DISTINCT

2007-06-03 Thread David Krings
Adrian Noland wrote: 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. Good to know. I heard about indices before, but wasn't really aware that they have such a huge impact. Since my days o

Re: [nyphp-talk] PHP array_unique vs. SQL DISTINCT

2007-06-03 Thread Adrian Noland
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 an

Re: [nyphp-talk] PHP array_unique vs. SQL DISTINCT

2007-06-03 Thread David Krings
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 onl

[nyphp-talk] PHP array_unique vs. SQL DISTINCT

2007-06-03 Thread David Krings
Hi! Which one is faster: PHP array_unique or SQL DISTINCT ? I learned about the DISTINCT key word for SQL some time ago and remember that pro developers always told me that SQL is faster than code. I tested a slightly complex select query across three tables and used DISTINCT. The tables have