+ 5
What is the faster: iterate array-list-enum directly or database directly?
I need your answers to toggle my project data to another one. Current i'm storing my data into a main Enum then I look is very slow iterate it all.
4 Réponses
+ 8
Hi @Lucas...
It really depends on several factors:
- Size of dataset.
- Filtering logic applied while iterating each data item.
- Sorting logic applied.
- Projection logic applied to reshape and format the data.
Databases can be optimized to work with larger datasets that involve indexing, caching, and algorithms for querying data and applying filtering, sorting, formatting, aggregation, grouping, etc.
However, if the dataset is small with little to no change in the resulting dataset, you will also need to consider the additional performance hit that comes with database include the following:
- Opening the database connection
- Sending the query command
- Waiting for the database to complete the query
- Receiving and deserializing the dataset response
- Closing the database connection
The time to complete the above steps will depend on the quality of the network, hardware, and load on the servers. For the most part, these performance hits are relatively insignificant.
If comparing a small amount of data and excluding the database connection part, the array-list-enum will likely still have a slight edge over the dataset result.
+ 3
@Robert: Yes... Indeed... Nothing quicker to reveal a developer out of his depths than bad data modeling and improper db optimizations.
+ 2
Humm... Good. Currently I have a big enum. Each enum item holds another objects and so on. Then, based on your answer, is better switch to database use?
This is what I'm thinking now.
+ 2
Great answer by David Carroll. I'd just add small thing to it. Bad data model, querying and/or db optimisation skills may hinder potential benefits that db can provide.