0

In a web project I perform a SELECT SQL query against an Indexed column of a table with 10-15 rows.

I want to ask you if it's good to cache this query in server memory as this SELECT against indexed tables is light and fast and its not complex at all. I cache to memory many things around (4GB) and I don't want to cache simple queries like this.

My question is what is the performance impact of this query if there is any against fetching cached data.

Spyros
  • 540
  • 1
  • 7
  • 21
  • 2
    you have 4GB of data in cache?? – Mitch Wheat Feb 08 '11 at 14:16
  • @Mitch Yes Microsoft Commerce Server 2007 internal cache and huge products catalog :/ – Spyros Feb 08 '11 at 14:19
  • An indexed table with only 15 rows, a query should not take more than 15-50 milliseconds depending on a lot of other things, assuming that your db server is local on the network. Caching these 15 rows is also not a big deal at all. It's not an easy question to answer. You have to performance test both options and see what makes sense to you. If you query is lightning fast but you do it 100 times a second, you should probably cache it. – e36M3 Feb 08 '11 at 14:20
  • If you're looking at "Cached" in the Task Manager, that's not what's in the IIS/ASP.NET cache. That's the OS Cache. – Keltex Feb 08 '11 at 14:21
  • @e36M3 it's 1 or 2 queries per specific page request – Spyros Feb 08 '11 at 14:23
  • @Keltex Yes I know , I'm talking about ASP.NET cache that saves in website application pool memory – Spyros Feb 08 '11 at 14:24

1 Answers1

2

It seems to me that the amount of space this data would actually take up in the cache is so small as to be almost insignificant. If the total cache space is 4GB, how much of that can this query possibly take up? Let's make a massively conservative assumption and say its 1MB of space. 1MB is 0.025% of 4GB.

Also, You can use the CacheItemPriority to assign a low priority to this data when entering it into the .NET cache if you want to. ASP.NET CacheItemPriority

Jason
  • 1,325
  • 6
  • 14