Category: Database

  1. Updated

    MongoDB Change Stream: react to real-time data changes

    Category: Database, JavaScript

    MongoDB Change Stream is a high-level API that allows you to subscribe to real-time notifications whenever there is a change in your MongoDB collections, databases, or the entire cluster, in an event-driven fashion.

  2. Updated

    MongoDB operations: Replica Set

    Category: Database, DevOps

    A replica set is a group of servers that maintain the same data set, with one primary which takes client requests, and multiple secondaries that keep copies of the primary's data. If the primary crashes, secondaries can elect a new primary from amongst themselves.

  3. Updated

    Import MySQL database but ignore specific tables

    Category: Database, DevOps

    You could just exclude tables you do not need.

  4. Updated

    MongoDB cookbook: Indexes

    Category: Database

    The order of fields in an index matters, you must consider Index Cardinality and Selectivity. Instead, the order of fields in a find() query doesn't affect whether it can use an index or not.

  5. Updated

    MongoDB cookbook: Queries and Aggregations

    Category: Database, JavaScript, Python

    Frequently accessed items are cached in memory, so that MongoDB can provide optimal response time.

  6. Updated

    MySQL system error codes

    Category: Database, DevOps

    Print all OS error codes and MySQL error codes using the perror command.

  7. Updated

    Convert utf8 tables to utf8mb4 in MySQL

    Category: Database

    Don't blindly copy-paste this!

  8. Updated

    Create a custom migration in Django

    Category: Database, Python

    ALTER TABLE app_repostarring CHANGE repo_description repo_description VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

  9. Updated

    Locking and MVCC in MySQL InnoDB 鎖機制與多版本並發控制

    Category: Database

    最近在研究 MySQL 5.6 / 5.7 InnoDB storage engine 的 Transaction、Locking 和 Multi-Version Concurrency Control (MVCC) 機制,基本上只討論 Isolation level 是 REPEATABLE READ 或 READ COMMITTED 的情況,這一篇是過程中記錄下來的筆記。

  10. Updated

    Django's get_or_create() may raise IntegrityError but subsequent get() raises DoesNotExist

    Category: Database, Python, Web Development

    get_or_create() 拋出 IntegrityError 但是接著 get() 一次卻會是 DoesNotExist,以上的錯誤常常會發生在 MySQL 的 isolation level 是 REPEATABLE READ 的情況下。MySQL 默認採用 REPEATABLE READ(而 PostgreSQL 預設是 READ COMMITTED)。