3 ms·
Use case for you based on a real example. Early Monday morning, your site goes down under load. You really want a DBA to be able to hop on it, identify that t
by btilly 13y ago
Use case for you based on a real example. Early Monday morning, your site goes down under load. You really want a DBA to be able to hop on it, identify that the cause is, for instance, a poorly executing query, and lock a decent query plan in place.
Oracle lets DBAs do that, but I've not seen a database migration tool that knows how to understand/express that.
Secondly when it comes time to update your schema, the easiest solution is to simply lock tables and do updates. However locking the table can involve a forced outage. If, however, you limit yourself to very specific kinds of updates, then you can update your schema without major outages. Now rolling forward is cheap. Rolling it back is very, very expensive. Tools generally just try to do what you asked, and don't know how to say, "Really?"
If you pay attention to this, then you want to be able to just roll forward. And you want to be able to roll your database forward independently of the web server. Now you have the option of rolling the database forward, then rolling out a new version of the web server code. Should you have an emergency problem, roll the web server code back, and leave the database on the new version. (This only works if the database is "dumb".)
One strategy to support this is to let the DBAs be in charge of the schema, separately from your development tree. Developers are allowed to create patches that alter the database on dev, and will submit those patches to the DBAs. If the DBAs do not object to the change, they are in charge of putting it on QA or production. (If the DBA does object, of course, it goes nowhere.)
And now the pattern is that DBAs maintain the official definition of the database. DBAs are willing to apply proven patches to production, and can make QA a clone of production whenever they want. In emergencies, DBAs can fix problems directly on production. (You try to have this happen as little as possible.) All developer changes to the database schema have to be blessed by DBAs. Database patches need to be applied in production separately from and strictly before release.
I've seen a number of different strategies for handling database schemas and code. This is the one that, in my opinion, worked best in practice.
- joevandyk 13y agoOracle lets DBAs do that, but I've not seen a database migration tool that knows how to understand/express that. I'm assuming that Oracle lets you do this via some sort of a sql file/script? I'd think the process would be: 1. Create SQL file that locks the query plan 2. Test it 3. Check into version control 4. Using migration tool, apply to production database PostgreSQL lets you do all sorts of updates without locks, fwiw, and that's what I'm most experienced with. And all postgresql administration can be done via text files that can be checked into version control.
- just_hobbyst 13y agoThat would be interesting - but I wonder if it makes sense. @btilly: what is the name of the thing with locking queries you referred to?
- btilly 13y agoAny upgrade script that does certain operations will lock tables as it goes. See your database documentation for details. This can include rebuilding indexes, removing columns, modifying existing columns, etc. Furthermore when you've got both stored procedures and tables changing, you have to get the order of operations correct. I'm not aware of any automated tool that can figure out the dependencies and do so correctly. (Mind you I have not looked recently.)
- btilly 13y agoI'm assuming that Oracle lets you do this via some sort of a sql file/script? Not that I know of. When I took the SQL tuning class where I learned about it, they had an interactive admin panel for tracking down, identifying, and fixing query plans. But I'm not a DBA, I haven't used Oracle in a few years, and I do not know what all is available there.