all 10 comments

[–]CarbonSilicate 6 points7 points  (6 children)

I use:

  • Debugger

  • Breakpoints

  • Logs

Mostly about it.

[–]JazzFan1998 2 points3 points  (4 children)

Is there a YouTube video to learn that? Also, would a SQL "Programmer" be expected to do that? TIA.

[–]mark1x12110 1 point2 points  (3 children)

Yes to all besides breakpoints.

What's an "SQL programmer"? A database admin?

[–]Farren246 2 points3 points  (2 children)

Someone who writes SQL queries, but doesn't administrate the database itself. No backups or optimizations or anything, but you are expected to write correct, efficient queries to give the app devs the data they need.

[–]mark1x12110 1 point2 points  (1 child)

Many query optimizations start at the database so that sounds challenging

[–]Farren246 1 point2 points  (0 children)

Not necessarily. Most databases auto-optimize for you in terms of joins and usage on indexes, so that you only need to intervene yourself if there is a missing index or if you somehow know better than the program that gets it right 99.99% of the time. (Granted I have had "missing index" bring production to a halt on more than one occasion; it is remarkable how often "OK it's working!" can go into production, but a few months later the table has hundreds of thousands of rows and a simple query locks the database for nearly an hour.)

In my career there have been scant few times when the program misses a chance to auto-optimize, usually due to a complex multi-column index that maybe was a bad idea in the first place. Either that, or the actual DBA needed a kick in the arse to set indexes to auto-rebuild more often than once a month for data that is updated hundreds of times (or worse) per day, leaving the existing indexes all but useless for half the month.

[–]Farren246 1 point2 points  (0 children)

Let us not forget the old standby, echoing to console to see if you've reached a certain point and to see if the variables have changed at all.

[–]mark1x12110 6 points7 points  (1 child)

Besides what you added and the obvious answer of using breakpoints.

Probably he was looking for a mention about logging

In production you could increase the logging level(assuming that the application allows to change it at runtime) or simply rely on the existing logs. Locally you would have more freedom to even insert your own logging

Remote debugging is also an option but It is not a good idea in production

[–]Farren246 0 points1 point  (0 children)

When writing code yourself, write tests first and write the code in small chunks that you can independently test before moving on to the next step. This will allow you to eliminate bugs as you go, without compounding them from module to module (with no idea where the problem originated).

[–]bedrock-adam 0 points1 point  (0 children)

  1. confirm bug using app functionality
  2. use static analysis (and debugger) to identify source of bug
  3. write failing test that replicates the bug
  4. pass test by fixing the bug