Is it worth caching a dictionary for foreign key values ​​in ASP.net?

I have a cache Dictionary<int, string>(within 20 minutes) that has ~ 120 ID / Name pairs for the lookup table. I iterate over this collection when populating the dropdown lists, and I'm sure this is faster than querying the database for a complete list every time.

My question is more about whether it makes sense to use this cached dictionary when displaying entries that have a foreign key in this lookup table.

Say this cached reference table is an EmployeeType table. If I were to query and display a list of names and types of employees, I had to query for EmployeeName and EmployeeTypeID and use my cached dictionary to grab the name EmployeeTypeIDs when each record is displayed, or is it faster just to have DB grab EmployeeName and JOIN to get EmployeeType line, bypassing the cached dictionary.

I know that both will work, but I'm interested in what will perform the fastest. Thanks for any help.

+3
source share
2 answers

Optimization 101 says don't do this unless you need to: - Tips for optimizing C # /. NET programs

, , , , , .

, , , , .

, , ! , , , , , RAM , , , , , OS/ORM/DB . , ORM , - , !

+2

, , , , , .

. , , , , , , , (.. , ), .

, , ( ), , .

+2

Source: https://habr.com/ru/post/1740549/


All Articles