[AccessD] Access Arrays

James Button jamesbutton at blueyonder.co.uk
Tue Oct 23 12:48:45 CDT 2018


More appropriate to considering array vs collection
Array needs to be defined with a size
And changing that - as in adding to an existing array usually requires the array to be recreated, if not by specific user code, then by the app's variable's memory management, as
(AFAIK) arrays have to be in a single contiguous block of memory.
Collections are managed using add and delete? Commands and are maintained within memory as a collection of memory allocations 

So processing all entries in an array will almost certainly be faster because there is only 1 memory area and the entries in it will be at offsets from the first entry
Processing entries from a collection will require the program to access an index to get at each elements memory, and that memory would have been handled by the RAM/pagefile facility as separate allocations so each element could ( depending on what your code does) be in a separate block on the pagefile.

So - load the data repository as a single action, knowing how many items and how big the items are, then just reference, but not updating the elements - Arrays probably the best option
Changing the size of the array  frequently  - array management overhead will probably be CPU consuming 
BUT - then the decision would be accepting the array creation and recreation overhead for the minimal read overhead, 
or - going for the minimal collection changing overhead over the larger access overhead.

Then again, maybe -  
Specify a large array so it does not need space reallocation and the existing entries copied to the new memory allocation 

Specify an array or dictionary to hold key values and collection entry key - well any method to avoiding the hardware searching for entries through the entire collection's memory allocations.
Or just, if the code would be doing multiple passes through the data elements look towards an array rather than a collection.

BUT - 
That's just my considerations - and their appropriateness depends on the application processes, the volume of data and the amount of RAM available for the process.
And
If others know different  ,or better - please post!

It depends on what you are doing with the data 

JimB  
   



-----Original Message-----
From: AccessD <accessd-bounces at databaseadvisors.com> On Behalf Of Jim Lawrence
Sent: Tuesday, October 23, 2018 6:04 PM
To: Access Developers discussion and problem solving <accessd at databaseadvisors.com>
Subject: Re: [AccessD] Access Arrays

Has anyone done any speed comparisons on collections vs arrays? ...And which Array type perform best and which Array operations are slower (est). Is it better to off-load Array data as text information for some processes?

Jim 

----- Original Message -----
From: "Gustav Brock" <gustav at cactus.dk>
To: "Access Developers discussion and problem solving" <accessd at databaseadvisors.com>
Sent: Tuesday, October 23, 2018 8:08:20 AM
Subject: Re: [AccessD] Access Arrays

Hi Arthur

You can dim it:

Dim MyArray(0 To 99) As Long

All elements will hold a zero.

/gustav

-----Oprindelig meddelelse-----
Fra: AccessD <accessd-bounces at databaseadvisors.com> På vegne af Arthur Fuller
Sendt: 23. oktober 2018 17:00
Til: Access Developers discussion and problem solving <accessd at databaseadvisors.com>
Emne: [AccessD] Access Arrays

It's been a while (too long!) since I've done any actual coding in Access, and it seems I've forgotten almost everything I once knew. Case in point:
arrays.

How do I create an array with 100 elements? x = Array(100) gives me an array of one element, not an array of 100 elements.

Also, can I create an array of 100 elements, each of which is a Long?

Your friendly old fart in Toronto.

--
Arthur 

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list