The Types of Changes

I would guess that most of you reading this piece are database professionals in some sense. Either you work on databases as a developer of some sort (app and/or database) or manage them as a DBA or sysadmin. In working with databases, I’m sure that you need to alter object structures. Maybe you perform a lot of changes, or maybe you just alter the schema occasionally, In either case, you need to make decisions on which changes to make.

I would guess that the most common changes are altering stored procs/views/functions. Often these are to handle new or updated business rules. In those cases, how do you ensure you haven’t added regressions? I would hope you had a set of test scripts to verify that your results are correct. If I were very optimistic, I’d hope that you had a set of automated tests, such as those you could write with tsqlt or the Microsoft Unit Test Framework.

I’m sure many of you add new columns to tables. What are these types of changes? Capturing new data? Splitting existing columns or de-normalizing data? In these cases, are you re-examining the data model to ensure the changes make sense?

Maybe even more importantly, if you are capturing new data, do you consider vertical partitions for the table? This can be a good way to separate out data in columns that isn’t queried as often. Despite most recommendations, lots of developers will still SELECT * from tables, which can flood the buffer cache with data that isn’t often needed by an application. Vertical partitions can reduce the impact of these types of queries.

For those of you that add new data, do you consider using different data types for your new data, or do you have a standard string/numeric/date type that you use? SQL Server (and other platforms) often have a variety of different data types that can save space, while still accommodating the requirements for a change. As an example, many people use datetime as a standard type when they just need a date. In this case, we could save 5 bytes per row by choosing a more appropriate type.

If you add status values or flags, have you considered bit storage for your values? Whether you use the bit datatype or bits in an int, you can dramatically save space in each row. Newer versions of SQL Server include T-SQL functions to help you work with bits, though I would hope most developers can handle simple AND/OR logic against an integer to test if a particular bit is set.

Most software under active development has a need to continually alter and modify the database to meet new requirements. While lots of us have experience in making these changes, and do so often, once we make a change it often becomes enshrined in our production system for years. I would hope that we feel confident in refactoring our code as needed, but the reality of what I often see is that people are loathe to change the database for fear of breaking our software. Even when the refactoring actually improves the performance of the application.

I’m curious what types of changes you often make, and how you go about deciding on the specifics of the change. Let us know about your approach in the discussion. I’m especially interested in how you might handle the various options for changes. Do you assume defaults or are you explicit in how you structure your ALTER code?

You might have a novel way of examining requests and implementing changes that can help others in learning to ensure they make better changes in their own system.

Steve Jones

Listen to the podcast at Libsyn, Spotify, or iTunes.

Note, podcasts are only available for a limited time online.

Posted in Editorial | Tagged | Comments Off on The Types of Changes

Advice I Like: Apologies

How to apologize: quickly, specifically, sincerely. Don’t ruin an apology with an excuse – from Excellent Advice for Living

This is great advice. I remember myself often saying “I’m sorry, but …”, which takes away from the I’m sorry. In fact, I wasn’t really sorry.

I’ve learned to just apologize. No excuses, no qualifications, just apologize for what you (or often, I), did. Leave it at that.

I’ve been posting New Words on Fridays from a book I was reading, however, a friend thought they were a little depressing. They should be as they are obscure sorrows. I like them because they make me think.

To counter-balance those, I’m adding in thoughts on advice, mostly from Kevin Kelley’s book. You can read all these posts under the advice tag.

Posted in Blog | Tagged , | Comments Off on Advice I Like: Apologies

Removing the REST Endpoint in the Data API Builder

The more I work with the Data API Builder (DAB), the more I lean towards GraphQL instead of REST. Rest isn’t bad, but it’s tough.

This is part of a series of posts on DAB that I’ve written. I also have articles at SQL Server Central about DAB.

Checking the Endpoint

In my first article and DAB, I set up things with defaults and exposed a table. As you can see, my REST endpoint is live and running.

2024-12_0250

I can also see this in Postman.

2024-12_0251

Wht if I want to remove this and only look at GraphQL? Let’s see what I need to do.

Removing the REST Runtime

In the config file, there is this section for the REST configuration at runtime.

2024-12_0252

I can remove this, but I’d hope I didn’t mess up the JSON. This is hard to read. Certainly this is something I can delete, but is there another way?

There is. In the DAB CLI  reference, one of the parameters is –rest.disabled. Let’s try that.

2024-12_0254

That doesn’t work. Hmmm, OK, let’s add the database type

2024-12_0255

Apparently init only creates new files.

There is an update verb, but that doesn’t work either.

2024-12_0253

I guess I’m editing the file. I remove the highlighted section above and the API starts.

2024-12_0256

Let’s check the REST endpoint. It appears to still work:

2024-12_0257

In the runtime, I see this log:

2024-12_0258

Weird. I see an error, but data is returned.

Looking down, I see this in my config for an entity. The REST is enabled.

2024-12_0263

I’ll change that to false and restart the DAB service. Now I see this. REST is still there, but this path is broken.

2024-12_0264

If I go to the root for /api, I get a 404. There’s still a response, as there is a service here running GraphQL, but the REST path for /api is gone.

2024-12_0264

Summary

I’m not sure this really works, as if I enable this for any entity, then the REST call works. If I add any entity without using the –rest: false parameter, the REST path is added by default, so my guess is this is likely to be randomly added back by developers if they don’t have a wrapper around the CLI that ensures no REST paths are enabled.

Posted in Blog | Tagged , | 2 Comments

The Managed Cloud Database Options

There are many, many choices for cloud database services these days. I would hope everyone is aware of the various IaaS options in public clouds with EC2, Azure VMs, GCP Compute Engine, and others. These are often the easiest way to move your workload, but you’ve really just moved a VM from one place to another (likely more expensive) place.

For managed databases, there are lots of choices, but you might not be aware of your options. I ran across an article that discusses the various flavors of managed databases in the big three public clouds for SQL Server. In the piece, there is a section that talks about when a managed database makes sense. I like that it discloses the development on a managed service is expensive.

The problem I have is that I know lots of companies that struggle when they don’t have a development environment that matches product. Invariably developers will use something in their local SQL Server/MySQL/Oracle/PostgreSQL database that doesn’t work in a managed service and causes no shortage of pain. Containers can help, but they’re not always available.

I won’t delve into details, but the article lightly looks at RDS (Amazon), Azure SQL DB and Managed Instance (Microsoft), and Cloud SQL (Google). There are pros and cons for all of them, but to me, the Google option is interesting. It gives you an instance (with SSIS/SSRS) and a proxy, but it does have limit you to instance restores. Same for RDS, which is a limitation I’d be worried about. Often I have an issue with a database, really often with just a table. Restoring a whole instance instead of a db might be a delay I wouldn’t want to deal with. I hope this changes over time, as not recovering a database from an instance is a big hole to me.

The comparison of hardware resources and performance seems to show Azure has the highest capacities, but as the article notes, if you approach the maximums, the cost is very high. I tend to agree there, and I think this is one of the things that gets lost when companies consider the cloud for workloads. They look at the maximums with an eye towards growth if they need it. Rarely, however, do they compute the increased cost if they’ve under-provisioned resources. There’s also the concern that trying to match CPU/RAM/disk from on-premises to the cloud isn’t easy. This often isn’t the same type of comparison that most of are used to with local machines.

The main thing I find too many people forgetting is that moving to the cloud is a new architecture. You likely need to rework/refactor/rewrite your application to work better. Part of that work is reducing the amount and frequency of data queries. Without changing those things, you likely will end up spending a lot more money than you expect. Possibly without getting the workload response you expect.

The cloud can work well for your application and database, but it’s not easy and it’s not quick.

Steve Jones

Listen to the podcast at Libsyn, Spotify, or iTunes.

Note, podcasts are only available for a limited time online.

Posted in Editorial | Tagged | Comments Off on The Managed Cloud Database Options