How to Build a Grown-Up Database
The way we manage a database is like dealing with infants – entities that require constant care and supervision.
There are several reasons why:
The first is Select n + 1. When Oren was a consultant, he would make a bet with all his new clients that on his first day, he could find the N + 1 issue before lunch. If he didn’t, the entire job would be free. Nobody ever won.
Every project would have N + 1 issues that demanded your application ferry requests back and forth to the database taxing your systems unnecessarily. On-premises, this would cost you and your users time. On a cloud platform, this also costs you money.
Another reason is that since the dawn of the digital database almost 50 years ago, to create a product page, you have to make at least ten queries to your database. You need to query for:
- Order lines
- Loyalty Rewards
- And more!
This is equivalent to your database coming under attack by your application! Every time your application has an itch, needs a pacifier, wants a bottle or feels gas – no matter how small the issue, the database has to tend to it.
What is a Grown-Up Database?
What does it mean grown-up?
Let’s apply this to people.
If you aren’t responsible for yourself, you aren’t a grown-up. If you need a babysitter, you are still a kid.
In database terms, if you need a DBA, you are not yet a grown-up database.
The Deciding Factor
RavenDB is a document database specifically designed to target this issue.
It can load and entire order all in one shot. That slashes your latency, requires no armada of tables and reduces complexity significantly. Not needing to attend to every small detail of a data query is a big part of a grown-up database. Managing enough of your workload for you is an adult level feature.
One client of RavenDB is a large enterprise quick-service restaurant with over 1.5 million instances of RavenDB running on point of sale systems throughout its 37,000 restaurants worldwide. The average age of an operator of the systems that use RavenDB is an 18-year-old cash register operator with zero experience in software development or database management.
Yet everything works!
As applications scale-out in functionality and the volume and diversity of data types continue to expand, it becomes increasingly harder for a DBA to make sense of everything that is going on, let alone manage it all.
A goal of RavenDB is to keep things as simple as possible so it can manage everything for you smoothly. This adds another layer of giving a DBA or babysitter the night off. As a document database, there are no tables.
Other Issues Your Database Should Handle like a Grown-Up
Take a simple query,
SELECT * FROM users WHERE EmailAddress = "jane_doe@ITmine.tech"
This should be easy, right? In most databases, a table scan will find this single point. But combining every record in your system takes time. It shouldn’t be so cumbersome. In a small data set, you won’t see the difference, but what happens when your data expands to the point where a table scan involves sifting through hundreds of thousands of rows?
What happens when you have so many users making so many queries that every extra nanosecond is felt millions of times over?
You can create an index for every query, so your database leaps right to the data that you need. RavenDB includes automatic indexes where for every query your application makes to the database, RavenDB will create a new index, access an index already available, or improve on an index. You achieve top speeds to service queries, even as your data scales out.
When an index isn’t used for a specified time, it is discarded. This is another grown-up issue for a database: How to optimize resource allocation to spare the DBA from having to manage it.
RavenDB Cloud uses burstable instances to keep your systems from getting throttled on the cloud. If a node performs too slow, for all purposes, it is a downed node. RavenDB assumes responsibility for high-availability with burstable indexes, assignment failover, even cluster-wide ACID to make sure that you can maintain several nodes at all times, keeping several places open to users at all times with data of the highest integrity.
Throughout this webinar, Oren gives you more examples of how a grown-up database lets you save resources, get more from your database with little effort, so you can put more of your energy into your application.