Coursera 笔记

Module 03 · Introducing Apache Cassandra: An Open-Source NoSQL Database

Reading: Cassandra Data Modeling and Querying Best PracticesCassandra 数据建模和查询最佳实践

Coursera ↗

This reading will teach you the best practices for Cassandra data modeling and querying.
本阅读将教你 Cassandra 数据建模和查询的最佳实践。

Cassandra is an open-source, non-relational, or NoSQL distributed database that is continuously available across multiple data centers and cloud availability zones. It provides a reliable data storage engine for applications with a broad range.
Cassandra 是一个开源的非关系型 NoSQL 分布式数据库,可在多个数据中心和云可用区中持续可用。它为具有广泛范围的应用程序提供可靠的数据存储引擎。

Understanding Cassandra's distributed architecture and data storage principles is crucial for designing data models and crafting efficient queries. Let's examine the best practices for achieving high performance, scalability, and efficiency in Cassandra.
理解 Cassandra 的分布式架构和数据存储原则对于设计数据模型和编写高效查询至关重要。让我们来探讨在 Cassandra 中实现高性能、可扩展性和效率的最佳实践。

Improved read and write performance 提升读写性能

An efficient data model enables data to be requested as a single request, reducing complex joins. However, it also enables Cassandra to retrieve data quickly from distributed storage.
高效的数据模型能够以单个请求获取数据,减少复杂的连接操作。然而,它也使 Cassandra 能够快速从分布式存储中检索数据。

Partition correctly 正确分区

A good partition key restricts hotspots and disproportionately stores the amount of data on a few nodes. It also avoids selecting high-cardinality or frequently updated fields as partition keys and restricts large partitions.
一个好的分区键可以限制热点,避免在少数节点上不均匀地存储大量数据。它还避免了将高基数或频繁更新的字段选为分区键,并限制了大型分区。

Data duplication 数据重复

Data duplication supports query patterns and uses primary keys across multiple tables to optimize queries without compromising performance.
数据重复支持查询模式,并利用跨多个表的主键来优化查询,而不会影响性能。

Avoid full table scans 避免全表扫描

Avoiding full table scans minimizes them and range queries without specifying a partition key. Full table scans are resource-intensive, compromising performance for large datasets.
避免全表扫描可以最小化全表扫描和未指定分区键的范围查询。全表扫描资源密集,会降低大数据集的性能。

Specify required columns 指定所需列

The data query from Cassandra specifies the SELECT statement's columns. Obtaining only the required columns reduces the usage of the network bandwidth and minimizes the amount of data transferred between nodes.
来自 Cassandra 的数据查询指定了 SELECT 语句的列。仅获取所需列可以减少网络带宽的使用,并最小化节点之间传输的数据量。

Prefer batch updates 优先使用批量更新

The batch update achieves atomicity and consistency for a group of write operations. However, it minimizes the overhead associated with network communication and coordination between nodes in the Cassandra cluster.
批量更新为一组写操作提供了原子性和一致性。然而,它最小化了 Cassandra 集群中网络通信和节点之间协调的开销。

Summary 摘要

In this reading, you've learned about the best practices for Cassandra data modeling and best practices. Such as:
在本次阅读中,您学习了关于 Cassandra 数据建模的最佳实践。例如:

  • Improved read and write performance
    提升读写性能
  • Partition correctly  正确分区
  • Data duplication  数据冗余
  • Avoid full table scans  避免全表扫描
  • Specify required columns  指定所需列
  • Prefer batch updates  优先批量更新