MySQL speed question (12, permasaged)

1 Name: #!/usr/bin/anonymous : 2009-08-09 08:04 ID:5FfRIDHu

I was wondering, when you have a large set of data in a MySQL table, is it faster to find the data you want with MySQL's Select function, or by dumping the whole table into a PHP array and searching through that?

Basically, which works faster with lots of data, PHP or MySQL?

6 Name: #!/usr/bin/anonymous : 2009-08-12 01:31 ID:OJY4A1Y5

>>4-5 are both failing to use the two important words that PHP programmers in general seem to be oblivious to: query optimization. If you write your queries properly, the database can cut down something that you might implement in three ugly nested loops manipulating two nested sets of associative arrays, as one btree lookup and a string comparison. Simply put, the database knows much more about the data than the view does.

However, in order to properly make use of this fact, you still need to construct your databases non-stupidly. That's where all those principles of normalizing data and setting up indexes and so on really make a difference between a big box that you throw all your paperwork into haphazardly and then sort them one at a time when trying to find what you want, versus a well-organized filing cabinet with labeled hanging folders in alphabetical order.

7 Name: #!/usr/bin/anonymous : 2009-09-03 10:23 ID:p65GPQ8h

>>6
Listen to this man.
And brush up your SQL.

8 Name: #!/usr/bin/anonymous : 2009-09-10 10:11 ID:MFuI8/mg

and you're all forgetting to remind OP that premature optimization is the root of all evil. are you sure it's the table lookup that's taking most of your time?

9 Name: #!/usr/bin/anonymous : 2009-09-11 00:24 ID:JQsxk87S

>>6

> MySQL
> query optimization

HAHHAHAHAHAHAH

10 Name: #!/usr/bin/anonymous : 2009-09-12 01:13 ID:Heaven

>>9
I never once said "MySQL" in >>6. However, it does have a (pithy) query optimizer, which nonetheless still beats what you could do in PHP alone.

11 Name: #!/usr/bin/anonymous : 2009-09-21 23:04 ID:LIuXLqkK

everyone knows the only way to optimize is assembly, you must write your cgis in assembly php is toy language enjoy your sql injection

12 Post deleted.

This thread has been closed. You cannot post in this thread any longer.