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

Posted by user169867 on Stack Overflow See other posts from Stack Overflow or by user169867
Published on 2010-04-10T03:22:00Z Indexed on 2010/04/10 3:23 UTC
Read the original article Hit count: 335

Filed under:
|

I have a Dictionary<int, string> cached (for 20 minutes) that has ~120 ID/Name pairs for a reference table. I iterate over this collection when populating dropdown lists and I'm pretty sure this is faster than querying the DB for the full list each time.

My question is more about if it makes sense to use this cached dictionary when displaying records that have a foreign key into this reference table.

Say this cached reference table is a EmployeeType table. If I were to query and display a list of employee names and types should I query for EmployeeName and EmployeeTypeID and use my cached dictionary to grab the EmployeeTypeIDs name as each record is displayed or is it faster to just have the DB grab the EmployeeName and JOIN to get the EmployeeType string bypassing the cached Dictionary all together.

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

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about database