I have few static tables that all users can pull them but none of the users can change those tables. what is the best way to save them on server for better performance ? cache / static variable / on Application level or other way I am not aware ? Thanks.
Asked
Active
Viewed 139 times
0
-
What do you mean with "static table" (database? DataTable? Or just a list of entities?) What do you mean with "users can pull them"? Read them? Access them? Do they do this van a application with user interface? Or access them by, lets say, SQL Server Management? – Martin Mulder Apr 28 '13 at 09:52
-
the tables come from DB.when user open page those tables come from DB but the users not allowed to change those tables – the_farmer Apr 28 '13 at 09:55
-
So, when the first user hits your site, you want to store some static data somewhere other than a database? you could use Application Caching (http://msdn.microsoft.com/en-us/library/ms178594.aspx) but I'm sure you will find a lot of information just searching SO. EDIT: I just found this http://stackoverflow.com/questions/5096544/application-vs-session-vs-cache – Christian Phillips Apr 28 '13 at 09:57
-
but the cache is can expired. what abut static variable?is it not better in this situation? – the_farmer Apr 28 '13 at 10:00
-
You can have a look at here: http://stackoverflow.com/questions/1308354/asp-net-caching-vs-static-variable-for-storing-a-dictionary – fatihk Apr 28 '13 at 10:01
-
Cache will expire and data will be reloaded. Users cannot change, but can de data be changed by some other proces? In that case expiration is good! Otherwise use a static variable. But...wow large is your data? If it is to large, it will not fit into memory. – Martin Mulder Apr 28 '13 at 10:02
-
I have in each table round 30 rows. the tables help to create the page with all kind of necessary data. – the_farmer Apr 28 '13 at 10:03
-
before you read from the cache, you would first check it still exists, or reload it. – Christian Phillips Apr 28 '13 at 10:04
-
yes,I know I will need to check if expired. but the question is in my case that the tables are never change is it better to use static variable instead of cache? – the_farmer Apr 28 '13 at 10:07
1 Answers
0
Reading your question and reading your comments if would go for a static variable.
Caching creates exta code en checks to find out if data is still present. It produces more database I/O. These are little performance losses.
A static variable has to be loaded once (I suggestion in a static constructor), adn from that point forward you can always use it without worrying if it is still there.
On the other hand, if the data in the database changes (by an update process or whatever), than you should go for caching.

Martin Mulder
- 12,642
- 3
- 25
- 54
-
is it matter how many rows and tables I have ? if I Have 7 tables with this kind of data and each have around 30 rows is it matter static or cache ? – the_farmer Apr 28 '13 at 10:20
-
It does not depend on the rows. It does demend on the total size of the data. For example: 1 row with 1000 columns with ints take as much memory as 1000 rows with 1 column of ints. In both cases (cache or static) your data must fit in memory. – Martin Mulder Apr 28 '13 at 10:25