There is an old joke about sweeping consequences in IT related to wildcard commands like “rm -rf *.”  However, there are ways to avoid getting bit by them. For example, we can do test runs and subset queries before doing the real thing.  While it is undoubtedly faster to rip off one of those commands, it is also dangerous.  This episode looks into some tricks of the trade I learned after countless times of being tripped up by this concept.

Sometimes Easy Creates Sweeping Consequences

A database is the best tool for examples of doing something quick and dirty that ends up costly.  We can see this even with resource usage before more significant effects like data loss or corruption.  The old SQL command of “SELECT * FROM …” is one of the first many people learn and the biggest culprit.  We do not see any problem with a table with a few rows.  However, once we move to millions of rows, we can quickly turn this quick call into a time-consuming one that ties up a lot of resources.  Even worse, we can add a join or two without constraints and bring a system to its knees.  It is easier to grab all the columns for a quick browse, but that can also drain more resources than desired.

Check Your Expectations

The database example is nice and clean because we can always add limiting constraints or do counts of result size.  These tools allow us to validate our query meets our expectations without fully running the query.  For example, we can do a select before a delete is run and ensure that the records we will delete are the ones we desire to remove.  Likewise, we can select before we update.  We can also do smaller selects to determine the result set size before joining those queries.  These are just a few examples; we can apply this to our other coding efforts and most life situations.

If you like this season, you will probably like Scott Adams’ book, “How to Fail at Almost Everything and Still Win Big: Kind of the Story of My Life.”

Rob Broadhead

Rob is a founder of, and frequent contributor to, Develpreneur. This includes the Building Better Developers podcast. He is also a longtime student of technology as a developer, designer, and manager of software solutions. Rob is the founder of RB Consulting and has managed to author a book about his family experiences as well as a few about becoming a better developer. In his free time, he stays busy raising five children (although a few have grown into adults). When he has a chance to breathe, he is on the ice playing hockey to relax.

Leave a Reply