Speaker A
So the question that we're trying to answer is what kinds of data structures are used between OLTP databases that are doing more transactional processing and analytics databases. And often the simple way to think about this is the difference between row storage and column storage. One of the kind of core components of this whole discussion of what database are you choosing, what database engine are you going to choose is there are three broad categories that databases fall into. And even this doesn't really capture them all, but the three broad categories that databases fall into are OLTP, OLAP, and HTAP. And we'll draw boxes here on the screen for each of them. So these databases are OLTP, that stands for online transaction processing. And basically what that means is it's kind of optimized for a lot of very small short transactions where you're reading small amounts of data. And this is the kind of database that powers most applications, right? Um, if you, you know, are on Twitter right now, right, or you're on YouTube or whatever, there's almost always some form of OLTP database. It might be MySQL, it might be Postgres, it might be some, you know, on Google, right, since Google owns YouTube, it's probably something like Google Spanner that's powering that or maybe something custom for YouTube, but it's a database that's designed to do things like look up users when they log in or when you load your profile, load the user preferences or load the users, um, you know, whatever light mode, dark mode settings, right? All the different things that you need to be able to fetch about users and about profiles and about accounts when you're interacting with an application typically get stored in an OLTP database because they're good at storing those, structuring those. Often it's a relational database, but even databases like MongoDB that aren't relational kind of fall into that OLTP category. So we could kind of just start writing a list, right? Like MySQL is in here, Postgres is in here. Uh, let's see, technically, uh, SQLite, although like SQLite maybe isn't the best for really high scale, but, you know, technically it falls into this category here. So like these databases fall nicely into the OLTP category. The other category or the next category is OLAP and the A there stands for analytics. So essentially this is instead [clears throat] of a database designed for inserting lots of small things, fetching lots of small things in a semi-random pattern, um, it's designed to do analytics on often big data sets, right? So if you think about the information that's displayed in a Spotify Wrapped or YouTube Wrapped, it's kind of an analysis of an entire year of your specific data set. But still, if you're a heavy user of Spotify or YouTube or whatever, that's like kind of a big chunk of data that it needs to do analysis on to figure out what was Ben's most listened to artist or most watched YouTube channel. But then there's also the bigger picture of just like as a business, a lot of businesses want to do analytics not just per user, but like over their whole user base, right? Like what's the average age of our user base so that we can better target that user base or what is, um, you know, what's the average amount of, you know, what time of day do people spend the most time on Twitter or on YouTube, right, or watching streams? So doing these kind of deeper analytics where you might have to analyze many gigabytes or even many terabytes worth of your users' data to come up with answers like to better run your business, to better help your customers, right, to do reporting at the end of the year and all of this kind of stuff. Although you can run those kind of queries on MySQL and Postgres and SQLite, they're not really tailored in terms of how they store the data on disk. Even within OLAP, there's kind of different subcategories, right? There's like, well, databases that work well for time series analytics or databases that work more for generic analytics and all this kind of stuff, right? Some examples are things like ClickHouse is a popular one for time series analytics, but also just analytics in general. Um, DuckDB. This is one actually. Why can't I spell? Apparently I can't spell. DuckDB. Um, most of you know I work at PlanetScale and we recently like released an integration with them and there's the MotherDuck cloud that you can use with them, right? Google BigQuery is what it's called, right? I always get BigQuery and BigTable, but this is like a Google one. Why am I forgetting what Amazon's, I think Amazon's is it called Redshift? Redshift. So all of [snorts] these kind of things, right? So these are like standalone either query engines or databases as a whole, uh, for doing analytics type stuff and again these are not comprehensive lists, right? There's more in this list, there's more in this list and then HTAP is kind of this hybrid, right? There's this, uh, sort of idealized goal out there and I like honestly don't really have much experience at all directly using HTAP databases but there's this idea that maybe you can build databases that take a hybrid approach and do both well. Um, the only one that obviously comes to my mind is like SingleStore. Especially when you're at scale, the idea of just putting everything in a single database and having just this one giant unified place where all your data is. It's a nice idea in theory, but in practice, you run into a bunch of issues with compute competing for each other or there's a lot of data duplication. So, how do you make sure all of the different formats and layouts that you have data stay in sync? Um, so like obviously there's still people that use these products, but I think, um, generally if you're at a large enough scale, a better approach is to kind of have separate databases or data pipelines for your OLTP and OLAP. Let's look here. We got an interesting question. So, do OLAP databases still use the same data structures in [snorts] OLTP like B+ trees and LSM trees? Good question. The answer is again unless you're doing a hybrid approach, the answer is generally no. Um, and let's talk about that. Actually, I have that on the list of things I wanted to talk about. There's a lot of nuance to this question because even like within OLTP, there's different ways you can lay data out. Within OLAP, there's different ways you can lay data out. You can have things that kind of borderline and take approaches from both. Um, but the big, the big difference, kind of the general broad way of thinking about the difference is row storage versus column storage and generally row-based storage aligns well with OLTP workloads and column-based storage aligns well with OLAP workloads.