Tag

unique index

0 views collected around this technical thread.

Aikesheng Open Source Community
Aikesheng Open Source Community
Sep 18, 2024 · Databases

InnoDB Locking Behavior for Unique Index Conflicts under READ‑COMMITTED Isolation

This article examines how MySQL 8.0.32 InnoDB handles locking when inserting a row that violates a unique index under the READ‑COMMITTED isolation level, detailing the preparation steps, observed lock types, the underlying mechanism, and the final cleanup actions.

InnoDBMySQLRead Committed
0 likes · 8 min read
InnoDB Locking Behavior for Unique Index Conflicts under READ‑COMMITTED Isolation
Aikesheng Open Source Community
Aikesheng Open Source Community
Sep 11, 2024 · Databases

What Lock Is Acquired When a Primary Key Index Conflict Occurs During INSERT

This article examines how InnoDB handles row locking when an INSERT triggers a primary‑key index conflict, detailing the lock types on primary and unique indexes, the implicit‑to‑explicit lock conversion, and the role of the supremum record in the locking process.

InnoDBMySQLlocking
0 likes · 10 min read
What Lock Is Acquired When a Primary Key Index Conflict Occurs During INSERT
JD Tech Talk
JD Tech Talk
Sep 5, 2024 · Databases

Why MySQL Auto‑Increment Primary Keys Can Become Non‑Continuous

This article explains the mechanisms behind MySQL auto‑increment primary keys, why gaps appear after failed inserts, unique‑index violations, transaction rollbacks, and batch operations, and how storage engines and innodb_autoinc_lock_mode settings influence the continuity of generated IDs.

DatabaseInnoDBMySQL
0 likes · 11 min read
Why MySQL Auto‑Increment Primary Keys Can Become Non‑Continuous
Aikesheng Open Source Community
Aikesheng Open Source Community
Jun 6, 2023 · Databases

Why Does Inserting a Record that Triggers a Unique Index Conflict Add a Next‑Key Exclusive Lock on the Primary‑Key Supremum Record?

This article reproduces a MySQL 8.0.32 InnoDB scenario where inserting a row that violates a unique index causes a next‑key exclusive lock on the primary‑key supremum record, explains the underlying implicit‑lock mechanism, walks through the relevant source‑code stack, and details the lock‑conversion and rollback steps under REPEATABLE‑READ isolation.

Database InternalsInnoDBMySQL
0 likes · 25 min read
Why Does Inserting a Record that Triggers a Unique Index Conflict Add a Next‑Key Exclusive Lock on the Primary‑Key Supremum Record?
Aikesheng Open Source Community
Aikesheng Open Source Community
Mar 6, 2023 · Databases

Adding Unique Indexes in MySQL: Methods, Risks, and Hook‑Based Mitigations

This article explains how to add unique indexes to large MySQL tables using Online DDL, pt‑osc, and gh‑ost, compares their advantages and drawbacks, outlines common data‑loss risks, and provides practical hook scripts and best‑practice recommendations to mitigate those risks.

MySQLdatabase migrationgh-ost
0 likes · 20 min read
Adding Unique Indexes in MySQL: Methods, Risks, and Hook‑Based Mitigations
Selected Java Interview Questions
Selected Java Interview Questions
Nov 1, 2022 · Databases

Understanding MySQL Unique Index Pitfalls and Practical Solutions

This article examines why a MySQL InnoDB table with a unique index can still store duplicate rows—especially when indexed columns contain NULL values or when logical deletion is used—and presents several practical strategies such as adjusting delete status, adding timestamp or auxiliary ID fields, using hash columns, and leveraging proper bulk‑insert techniques to enforce uniqueness effectively.

Database DesignMySQLNull Handling
0 likes · 13 min read
Understanding MySQL Unique Index Pitfalls and Practical Solutions
macrozheng
macrozheng
Aug 16, 2022 · Databases

Why MySQL Unique Indexes Still Allow Duplicates and How to Fix Them

This article explores a common MySQL InnoDB pitfall where unique indexes fail to prevent duplicate rows, explains how NULL values and logical deletion affect uniqueness, and presents practical strategies—including composite keys, delete status counters, timestamps, hash fields, and Redis locks—to enforce true uniqueness.

Database DesignMySQLNull Handling
0 likes · 14 min read
Why MySQL Unique Indexes Still Allow Duplicates and How to Fix Them
360 Tech Engineering
360 Tech Engineering
May 7, 2021 · Databases

MongoDB Sharding Key Query Failure and Unique Index Violation Explained

This article reproduces a MongoDB issue where queries using a hashed sharding key return no results and a unique compound index appears to fail, then explains the root cause—index entries exceeding the 1024‑byte limit and the failIndexKeyTooLong parameter—providing step‑by‑step commands, configuration changes, and practical recommendations.

DatabaseIndexingMongoDB
0 likes · 35 min read
MongoDB Sharding Key Query Failure and Unique Index Violation Explained
Architecture Digest
Architecture Digest
Mar 15, 2021 · Databases

Impact of UNIQUE Indexes in MySQL and Strategies to Avoid Duplicate Key Errors

This article explains how MySQL UNIQUE indexes affect data insertion and auto‑increment behavior, compares them with primary keys, and presents three techniques—INSERT IGNORE, REPLACE INTO, and INSERT … ON DUPLICATE KEY UPDATE—to prevent duplicate‑key failures, including deadlock considerations.

DatabaseINSERT IGNOREMySQL
0 likes · 8 min read
Impact of UNIQUE Indexes in MySQL and Strategies to Avoid Duplicate Key Errors
Selected Java Interview Questions
Selected Java Interview Questions
Mar 6, 2020 · Databases

Best Practices for Choosing Database Indexes

This article outlines essential principles for selecting and managing database indexes, covering unique indexes, indexing frequently sorted or filtered columns, limiting index count, using short or prefix indexes, removing unused indexes, left‑most prefix matching, column cardinality, avoiding functions on indexed columns, and extending existing indexes.

MySQLPerformance OptimizationQuery Optimization
0 likes · 7 min read
Best Practices for Choosing Database Indexes
Qunar Tech Salon
Qunar Tech Salon
Jun 27, 2017 · Databases

Database Deadlock Cases and Their Resolutions

This article examines three real‑world MySQL deadlock incidents—unique‑key null insertion, concurrent duplicate‑key insertion, and a JDBC parameter bug—detailing their detection, analysis, and the concrete fixes applied to prevent recurrence.

ConcurrencyJDBCMySQL
0 likes · 9 min read
Database Deadlock Cases and Their Resolutions