Posts

Super fast Contains search on a list

If you need to do this, use HashSet<T> which is 100X faster!

Entity Framework Gotcha

If you want to migrate a lot of data which means running updates to existing rows, it is 100X faster to first change the objects then run a single save changes call, instead of doing row by row call. Also, when batching such operations say by 5000 rows, re-initialize the entities object each time, otherwise it will cache everything progressively getting slower over time.

Fastest Serializer for .NET and C#

I just ran a benchmark today. DataContractSerializer runs pretty fast, but The DataContractJsonSerializer can serialize faster. Note however that the DataContractSerializer can deserialize faster than the Json. Deserialization times: Binary: 198 ms DC: 20 ms Json: 74 ms Serialization times: Binary: 191 ms DC: 0.3 ms Json: 0.2 ms When the size of data increases, Binary slows down faster than other techniques. Also, the size of the data is significantly smaller for Json and DC.

Another way to do a not exists SQL query with best performance

This comes up again and again as a thorny and persistent problem. I got this new way of doing this from my friend. SELECT alias1. PKCol1 , alias1.Col2 FROM table1 alias1 WHERE alias1.Col3= 11 AND alias1.Col4= 43 AND       NOT EXISTS (SELECT 'x' FROM table2 alias2 WHERE alias2. PKCol1 = alias1. PKCol1 )

Azure App failing after upgrade to SDK 2.1?

There are many posts online without answers to this problem. No errors are seen anywhere - it may give RoleEnvironment errors or host not found errors. Basically to fix this, just go through all your projects and ensure that the dlls are referencing the correct azure version. In my case, Microsoft.WindowsAzure.ServiceRuntime.dll was referenced to v2.0 and it was giving the problem. Just change it to v2.1 for ALL projects.

Caching is not as easy as you think it is

For the past year I have been playing around with azure caching and learning a lot. I have got frustrated, confused and then finally there seems to be light at the end of the tunnel. This is what I've learnt from my experience so far: 1. I have no idea why they allow co-located caching because if you are having a decent sized cache with lots of reads and writes, this is unusable. Use dedicated cache role - only that can handle significant load. 2. Caching which uses BLOB storage as a persistence mechanism has problems if it accesses BLOB storage frequently because items are not remaining in the cache. I was flummoxed by this problem but worked around it because in my case, I was able to get away with checking for the existence of the BLOB which is much faster than trying to download it every time (my data just requires the existence check). 3. Don't be unhappy with your code if you have x-small and small instances and your sites with caching roles do not perform well. ...

c# async method without a real await supported method called within it.

Have been searching for this since a long time. Finally found it: http://stackoverflow.com/questions/15522900/how-to-safely-call-an-async-method-in-c-sharp-without-await public   async   static   Task < int > GetTwitterResultsCountAsync( string  itemLink)         {              int  returnCount =  await   Task .Run< int >(() =>             {                  int  count = 0;                  try                 {                 ...