Posts

Surprising SQL speed increase

I’ve just found out that the execution plan performance between the following two select statements are massively different: select * from your_large_table where LEFT(some_string_field, 4) = ' 2505 ' select * from your_large_table where some_string_field like ' 2505% ' The execution plans are 98% and 2% respectively. Bit of a difference in speed then. There are lots of places in our SQL where we use LEFT(something, x) = 'string' This should be replaced by the LIKE command for greater speed. I actually found this out by checking the LINQ generated SQL against my hand crafted SQL. I assumed the LIKE command would be slower, but is in fact much much faster.

A generic singleton

Taken from: http://andyclymer.blogspot.com/2008/02/true-generic-singleton.html Changed by Simon Hughes 20th Feb 2008 using System; using System.Reflection; // Use like this /* public class Highlander : Singleton<Highlander> { private Highlander() { Console.WriteLine("There can be only one..."); } } */ public class Singleton <T> where T : class { private static T instance; private static object initLock = new object (); public static T GetInstance() { if (instance == null ) { CreateInstance(); } return instance; } private static void CreateInstance() { lock (initLock) { if (instance == null ) { Type t = typeof (T); // Ensure there are no public constructors... ConstructorInfo [] ctors = t.GetConstructors(); if (ctors.Length > 0 ) ...

BypassProxyOnLocal - a bug in .Net ?

If you have a local proxy server on your computer (127.0.0.1) that you wish to use when doing FTP communications, all you need do is set BypassProxyOnLocal = false right? There may be many important reasons for using a local proxy, such as caching and security etc. Here's an example: WebProxy proxy = new WebProxy("127.0.0.1", 3128); proxy.BypassProxyOnLocal = true; bool a = proxy.IsBypassed(new Uri("ftp://127.0.0.1:3128")); bool b = proxy.IsBypassed(new Uri("ftp://127.0.0.1:21")); // a=true, b=true (ok) proxy.BypassProxyOnLocal = false; bool c = proxy.IsBypassed(new Uri("ftp://127.0.0.1:3128")); bool d = proxy.IsBypassed(new Uri("ftp://127.0.0.1:21")); // c=true, d=true (???) Why is the proxy being bypassed when I told it not to? The local proxy is always bypassed when when the proxy is on a loopback address. Why? Setting BypassProxyOnLocal to false should NOT bypass the proxy for local addresses. So let's see what MSDN Library ...

Design patterns

I've recently been on a training course with http://www.developmentor.com/ it's called Code Smarter with Design Patterns in .NET and can strongly recommend it. I simply love design patterns, and you should to :-)

GRC.COM by Steve Gibson

https://www.grc.com/ is run by Steve Gibson. He has many great utilities and has a Security Now podcast. I can't recommend them strongly enough. GRC "Perfect Passwords" Generator https://www.grc.com/passwords.htm Spinrite hard disc recovery and maintenance http://www.grc.com/spinrite.htm SecurityNow podcast with Leo Laporte http://www.grc.com/securitynow.htm ShieldsUP! https://www.grc.com/x/ne.dll?bh0bkyd2 SecurAble http://www.grc.com/securable.htm

DHCP Client service causing my PC to go slow

Recently I’ve noticed my laptop going quite slow. For example, using Windows explorer and clicking on a folder resulted in a 40 – 60 second wait for the folder to show its contents. Well, I’ve worked out by stopping the ‘DHCP Client’ service my PC goes like lightening again. I'm also using Windows XP. To fix, you need to delete all Printers that are offline, and remove all mapped network drives. Why does the ‘DHCP Client’ affect windows explorer? I don’t know, but Microsoft if your reading this, please fix it.

What do I use to write software?

I started off with Dbase III, then Borland Turbo C for about 5 years, then when Microsoft Visual Studio v1.0 came out, I moved to that. I've been using Visual Studio ever since. Coding in C++ and have since moved to C# when that came into existance. Do I use component? Yes. Which ones then? Telerik http://www.telerik.com/ Dundas http://www.dundas.com/ Rebex http://www.rebex.net/ I've also used DevExpress reports, but they peg the CPU to 100% on the webservers when exporting an excel spreadsheet with a lot of data in them, and more often than not, cause a timeout on the ASPX page. So I don't like to use them anymore. My essential toolkit consists of: SVN - Subversion source control http://subversion.tigris.org/ Winrar http://www.rarlab.com/ Colour Schemer (web design) http://www.colorschemer.com/online.html SQL Prompt http://www.red-gate.com/ ANTS Profiler http://www.red-gate.com/ NUnit http://www.nunit.org/ Microsoft Visual Studio http://msdn2.microsoft.com/en-gb/vstudio/de...