java - Is accessing data from database faster than accessing from Arraylist -


i have 10000+ records in file. read file , keep records in arraylist, web application reads arraylist frequently.

i perform reading operation on arraylist.

however performance of web application slow.

will better keep data file in database , read database.

or there other collection can use.

with arraylist<myrecord> don't have lookup method, code doing sequence searches whenever need find record.

if ever lookup 1 value, e.g. name, change hashmap<string, myrecord>. allow direct lookup without need sequence search.

if lookup various values, keep arraylist<myrecord> around, build multiple maps, 1 each lookup field (or set of fields).

the maps same indexes in database.

now, if data updated, things different. update require write entire file again, immediately? if program dies halfway through write? databases have built-in guards prevent data loss, , allow sharing data among multiple programs running @ same time.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -