Ready to watch this entire course?
Become a member and get unlimited access to the entire skills library of over 4,900 courses, including more Developer and personalized recommendations.Start Your Free Trial Now
- View Offline
- What is NoSQL?
- Installing CouchDB on Mac, Windows, and Linux
- Storing data
- Nesting document data
- Specifying search criteria
- Reducing data
- Attaching and retrieving images
- Deploying applications
- Securing CouchDB
- Understanding the CAP theorem
Skill Level Intermediate
As a database grows in size, maintaining acceptable performance becomes more complex. Partitioning is one method you use to help manage large and busy databases. So what is database partitioning? Database partitioning is splitting data across multiple database servers. Partitioning is always done by consistent method so you always know where the data is. There are several different methods that you can use. One partitioning method you can use is a range. For instance, if you had your database sorted alphabetically you could have records A through L on one partition, M through Q on another, and R through Z on a third.
Another method for partitioning is a list. If you were building a database of books you could categorize them. You can have textbooks on one partition, cookbooks on another and sci-fi books on a third. And finally, you could use a hash as a partition method. With a hash you pass a value into a function, and it returns a value to determine the membership. So why would you partition in the first place? One reason might be storage limitations. If you have a very large dataset, that entire set might not fit on one database server.
Another common reason is for performance. When you split the load between partitions, it can make it faster to write to the database. And then finally, you might want to partition for availability. Placing your data on separate partitions insures that you're always going to be able to get to the data even if one of the partitions gets busy. Although there are scenarios where you would want to partition your database, there are also scenarios where you would not. When your dataset is small, there's no reason to partition. It will only increase the complexity of your database server.
Partitioning in relational databases and NoSQL databases is similar. Relational databases can be partitioned horizontally or vertically. Horizontal partitioning, which is also known as sharding, puts different rows on different partitions. Vertical partitioning on the other hand, puts different columns on different partitions. Partitioning non-relational databases depends on the database type. Key value and document databases are typically partitioned horizontally. On the other hand, tabular databases can be horizontally and vertically partitioned.
Many NoSQL databases are designed with partitioning in mind, however smaller databases may not need partitioning. Understanding how partitioning works is key to making informed decisions about database performance.