Posts

Showing posts from October, 2013

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 )