• Post Reply Bookmark Topic Watch Topic
  • New Topic

HashMap versus database  RSS feed

 
Adi Kulkarni
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

What would be more efficient?

Storing around 50k to 70k rows in a hashMap and retrieving them often or to create a table in the database and retrieving.

Will it be possible to just store so many rows in the java structure ? These many objects without being garbage collected can cause an overflow right ?

~Aditya
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adi Kulkarni wrote:
What would be more efficient?
Storing around 50k to 70k rows in a hashMap and retrieving them often or to create a table in the database and retrieving.


[i am not sure] in this case i think Database would be a better choice also read this
 
Adi Kulkarni
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks seetharaman.

But if storing 50000,70000 objects in a hashmap is possible by increasing the heap size , then retrieving those would be faster than retrieving from the database right?

~Aditya
 
Vijay Kumar koganti
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adi Kulkarni wrote:Thanks seetharaman.

But if storing 50000,70000 objects in a hashmap is possible by increasing the heap size , then retrieving those would be faster than retrieving from the database right?

~Aditya


I believe it depends on whether you need your data to be persisted for future and if the 70000 odd objects are just required for your logical processing it is better to use HashMap and they are certainly faster than the Database operations for sure.

regards,
vijay
 
Adi Kulkarni
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Vijay,

I would need the data for future. So I believe that using the database would be better though slower. Moreover my database would be a dynamic one which would be updated time to time.

~Aditya
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!