One of my mantras is '!@#$ing Microsoft'
Recently had a teammate show me a simple rewrite of one (Microsoft SQL) line: orig: a is not null or b is not null, new: not (a is null and b is null). Logically equivalent. From two hours to twenty seconds?!?
Hold up. You are claiming that an application of De Morgan's Law on that simple SQL query sped up your run-time by 360x?
I don't have much experience with SQL, so take this as just a request for info with merely a tinge of scepticism (rather than full-on scepticism.) But:
(assuming 'a' and 'b' both represent SQL queries)
* Your 'orig' looks like it would often get away with just 1 query (i.e, if 'a' proves to be not-null, then no point querying 'b')
* Your 'new' looks like it would always perform 2 queries
Which leads me to the following observations:
* 'orig' actually looks to be more performant that 'new'
* Even if you just accidentally swapped your telling of 'orig' and 'new' in your comment here, still at best you are looking at a 2x speed up, not the 360x speedup you are claiming.