From 727a2f8bba898010ee72a8d8405b16ef91630489 Mon Sep 17 00:00:00 2001 From: John Richardson <42470533+John-Richardson@users.noreply.github.com> Date: Tue, 7 Jul 2020 03:05:50 +0200 Subject: [PATCH] Remove redundant SQL index in Pastebin exercise (#405) --- solutions/system_design/pastebin/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solutions/system_design/pastebin/README.md b/solutions/system_design/pastebin/README.md index 756c78c2..2d87ddcc 100644 --- a/solutions/system_design/pastebin/README.md +++ b/solutions/system_design/pastebin/README.md @@ -116,7 +116,7 @@ paste_path varchar(255) NOT NULL PRIMARY KEY(shortlink) ``` -We'll create an [index](https://github.com/donnemartin/system-design-primer#use-good-indices) on `shortlink ` and `created_at` to speed up lookups (log-time instead of scanning the entire table) and to keep the data in memory. Reading 1 MB sequentially from memory takes about 250 microseconds, while reading from SSD takes 4x and from disk takes 80x longer.1 +Setting the primary key to be based on the `shortlink` column creates an [index](https://github.com/donnemartin/system-design-primer#use-good-indices) that the database uses to enforce uniqueness. We'll create an additional index on `created_at` to speed up lookups (log-time instead of scanning the entire table) and to keep the data in memory. Reading 1 MB sequentially from memory takes about 250 microseconds, while reading from SSD takes 4x and from disk takes 80x longer.1 To generate the unique url, we could: