Welcome Guest, Not a member yet? Register   Sign In
huge php array

PHP uses a linked list for it's arrays, as opposed to what is naturally thought of as an array (that is, "n" fixed sized frames of a specific type, or a list of memory pointers, all sequentially stored in the memory space). The computational expense with a linked list is greater than for a classical array due to the way the data is structured, and so searching through (and thus sorting) a PHP array is expensive. Some people will say that a mergesort algorithm on a linked list acts at the theoretical maximum for sorting of O(n log n) (big Oh) but in general that isn't the case.

MySQL on the other hand should have each column you want to test pre-sorted (if you index the columns, which you should for anything required in a WHERE, ORDER, or GROUP clause) so the cost is greatly reduced so the only cost is from calculation. Secondly MySQL has type strictness on each column so it doesn't have to test the cast on each figure before calculation.

tl;dr : doing everything in MySQL is (most probably) the faster solution.

Messages In This Thread
huge php array - by El Forum - 03-17-2010, 08:56 PM
huge php array - by El Forum - 03-17-2010, 09:15 PM
huge php array - by El Forum - 03-17-2010, 09:58 PM
huge php array - by El Forum - 03-18-2010, 05:12 AM

Theme © iAndrew 2016 - Forum software by © MyBB