By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,747 Members | 2,039 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,747 IT Pros & Developers. It's quick & easy.

Speed of data access in arrays

P: n/a
Will calling ksort() on an array speed up it's access?

For example, I have the array $file_index, which is accessed by a key (the
entry id) and has two sub elements in a one dimensional array (line number
of the start of the entry in the file, and the byte offset of the start of
the entry).

so, I might have an array that can be represented thus:

{
2 => {1, 100),
4 => (30, 556),
10 => (376, 2637),
...
}

These usually have thousands of entries, so the arrays are quite large, and
anything I can do to speed up the data access will be big.

One file, contains under 10MB of data in under 2000 entries, the next
contains about 35MB of data in around 8000 entries, and the final contains
about 125MB of data in 20000+ entries, and I'm noticing significant lag on
the latter, so I was hoping to find a way to speed up the array access.
Thanks for the help
-Jim Stapleton
Jul 16 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Steven James Samuel Stapleton wrote:
One file, contains under 10MB of data in under 2000 entries, the next
contains about 35MB of data in around 8000 entries, and the final contains
about 125MB of data in 20000+ entries, and I'm noticing significant lag on
the latter, so I was hoping to find a way to speed up the array access.


No, sorting won't help.

--
Seks, seksić, seksolatki... news:pl.soc.seks.moderowana
http://hyperreal.info { iWanToDie } WiNoNa ) (
http://szatanowskie-ladacznice.0-700.pl foReVeR( * )
Poznaj jej zwiewne kształty... http://www.opera.com 007
Jul 16 '05 #2

P: n/a
Does anyone know of a way to speed up the access?

-Jim Stapleton
-PCF

"Adam i Agnieszka Gasiorowski FNORD" <ag*****@venus.ci.uw.edu.pl> wrote in
message news:3F***************@venus.ci.uw.edu.pl...
Steven James Samuel Stapleton wrote:
One file, contains under 10MB of data in under 2000 entries, the next
contains about 35MB of data in around 8000 entries, and the final contains about 125MB of data in 20000+ entries, and I'm noticing significant lag on the latter, so I was hoping to find a way to speed up the array access.


No, sorting won't help.

--
Seks, seksić, seksolatki... news:pl.soc.seks.moderowana
http://hyperreal.info { iWanToDie } WiNoNa ) (
http://szatanowskie-ladacznice.0-700.pl foReVeR( * )
Poznaj jej zwiewne kształty... http://www.opera.com 007

Jul 16 '05 #3

P: n/a
Steven James Samuel Stapleton wrote:
Does anyone know of a way to speed up the access?

-Jim Stapleton
-PCF

"Adam i Agnieszka Gasiorowski FNORD" <ag*****@venus.ci.uw.edu.pl> wrote in
message news:3F***************@venus.ci.uw.edu.pl...
Steven James Samuel Stapleton wrote:
> One file, contains under 10MB of data in under 2000 entries, the next
> contains about 35MB of data in around 8000 entries, and the final contains > about 125MB of data in 20000+ entries, and I'm noticing significant lag on > the latter, so I was hoping to find a way to speed up the array access.


No, sorting won't help.


Store it in a DBMS like MySQL - that's what they're designed to do
Jul 16 '05 #4

P: n/a
> Store it in a DBMS like MySQL - that's what they're designed to do

A DBMS is faster than an array?

-Jim Stapleton
Jul 16 '05 #5

P: n/a
Steven James Samuel Stapleton wrote...
Does anyone know of a way to speed up the access?


Have you tried increasing the memory limit in php.ini?
memory_limit = 256M
.... maybe buy more RAM for you computer

HTH
Jul 16 '05 #6

P: n/a
Steven James Samuel Stapleton wrote:
Store it in a DBMS like MySQL - that's what they're designed to do


A DBMS is faster than an array?

-Jim Stapleton


No, but it's faster than dealing with a file, reading it in and parsing
it, sorting an array, etc, as tyhe code in a DBMS is optimised for the
tasks, rather than generalised coding support.

You'll probably also find thjat a good DBMS will scale better on certain
operations with large sets of data
Jul 16 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.