Thinking Big Picture

As a developer, it’s very easy to get caught up in the minute details. Many issues take lots of time to delve into very specific, intricate pieces of code. Although this is the case most of the time, some things only require the simplest, most obvious of fixes. Well, these quick fixes are almost always going to be unseen when we have our blinders on for complex causes.

Something I, and probably many other developers forget often, is to step back and look at the bigger picture. I had a case recently to figure out why some lines didn’t have entries in a certain table. I checked the logs for the lines, where they were changed, when they were changed, what configurations were edited, etc. Had I stepped back and looked at the table that held the most simplest of line configurations, I would’ve seen that they were test lines and didn’t even particularly matter.

In this instance, looking at the bigger picture would’ve saved valuable development time. So how do we know when to look bigger? Well, I think when it comes to development that it never hurts to take a few minutes and check the basics. Instead of diving straight into checking the database and page setup for why a variable isn’t defined, maybe just check the syntax where it’s set. Countless times i’ve come to find that there’s just an extra space or special character getting in the way.

There was a good example of this scenario recently. Given this issue, what would be your steps to troubleshoot?

Google.com is not rotating

  1. Check the website (no rotation)
  2. Check the WST pool configuration (all good)
  3. Check the website for our script (placed)
  4. Check for console errors/correct placement (all good)

What, then, could be the problem? Well we all just assume that the pool is set up under Google.com. If you put that in a string it would look like this: ‘Google.com’. The overarching problem in this case was the string: ‘ Google.com’. One space before the URL broke everything. This is a quick, basic fix.

So whenever you have a problem to look at,  try to keep in mind the simple things. Before getting too immersed in things, just look at the big picture and you might just find a fix there.

Instruments for the Occasion

Chances are, if you’ve ever been to a college football game, you’ve heard the drum-line. The loud crashes of cymbals, tight tap of the snares, deep tones of the bass drums, you get the idea. In order to get these specific sounds, different tools are used. Quads use special mallets, as does the pit according to whatever instrument is being played. You wouldn’t use brushes on a snare drum just as you wouldn’t use bass beaters on a xylophone.

Percussion_Beaters

Writing Microsoft SQL queries is the same way. Just as specified mallets and sticks are used in drum-line, different SQL techniques are used depending on the situation.


select refname, lskinid, round(sum(leminutes), 2) as 'Minutes' from lskin
	join hproduct_lskin on frn_lskinid = lskinid
	join dnis on add_lskinid = frn_lskinid
	join archive.dbo.xcall_2014 on cf_frn_dnisid = dnisid
		and tz_date between '2014-01-01' and '2014-03-01'
where frn_hproductid = 1
group by refname, lskinidRegular_time

Above is just a basic query; nothing special, just some joins. As you can see, it took 1 minute and 58 seconds to complete.

with CTE (refname, lskinid, dnisid)
as (
select refname, lskinid, dnisid from lskin
	join hproduct_lskin on frn_lskinid = lskinid
	join dnis on add_lskinid = frn_lskinid
where frn_hproductid = 1
)
select refname, lskinid, round(sum(leminutes), 2) as 'Minutes' 
from CTE c
	join archive.dbo.xcall_2014 on cf_frn_dnisid = c.dnisid
		and tz_date between '2014-01-01' and '2014-03-01'
group by refname, lskinidCTE_time

This takes the same query and separates it into 2 parts using a CTE. Changing the technique cut the time down to only 8 seconds.

declare @TempTable table (refname varchar(155), lskinid int, dnisid int)

insert into @TempTable (refname,lskinid, dnisid)
(
select refname, lskinid, dnisid from lskin
	join hproduct_lskin on frn_lskinid = lskinid
	join dnis on add_lskinid = frn_lskinid
where frn_hproductid = 1
)
select refname, lskinid, round(sum(leminutes), 2) as 'Minutes' 
from @TempTable t
	join archive.dbo.xcall_2014 on cf_frn_dnisid = t.dnisid
		and tz_date between '2014-01-01' and '2014-03-01'
group by refname, lskinidTempTable_time

Again, just a different technique (using a Temp Table) cut the query down to 8 seconds.


Those are just a few examples of query techniques in SQL. So next time you have to write a query, make sure you’re using the right ‘instrument’ for the occasion.