Skip to content

Commit 727a2f8

Browse files
Remove redundant SQL index in Pastebin exercise (donnemartin#405)
1 parent cc11a9b commit 727a2f8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

solutions/system_design/pastebin/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ paste_path varchar(255) NOT NULL
116116
PRIMARY KEY(shortlink)
117117
```
118118

119-
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.<sup><a href=https://github.com/donnemartin/system-design-primer#latency-numbers-every-programmer-should-know>1</a></sup>
119+
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.<sup><a href=https://github.com/donnemartin/system-design-primer#latency-numbers-every-programmer-should-know>1</a></sup>
120120

121121
To generate the unique url, we could:
122122

0 commit comments

Comments
 (0)