Commit b0ad9d4
authored
fix!: Split max index length between PKs (#13569)
#### Summary
Fixes #13486. The max length of an index is either `3072` bytes or `767` bytes.
Since we use `utf8mb4` which can use up to 4 bytes per char, we max out at either `768` or `191` chars (the number in bytes divided by `4`).
The current code allocates `191` chars per PK which is OK if a table has 4 PKs since `191*4= 764`, but fails if a table has more than that. See list of tables [here](#13486 (comment))
The solution is to get the max number of bytes based on the row format, and evenly distribute the max length between PKs.
This is still not the best solution as we assign the same number of bytes to a UUID and a `text` column (for example CQId is `UUID`), but I don't think it's very common to have one UUID PK and another `text` PK and enough other PKs so the prefix is too short.
<!--1 parent f22bfa6 commit b0ad9d4
3 files changed
+32
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
77 | 79 | | |
78 | 80 | | |
79 | 81 | | |
| 82 | + | |
| 83 | + | |
80 | 84 | | |
81 | 85 | | |
82 | 86 | | |
| |||
118 | 122 | | |
119 | 123 | | |
120 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
121 | 145 | | |
122 | 146 | | |
123 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | 16 | | |
19 | 17 | | |
20 | 18 | | |
21 | 19 | | |
22 | | - | |
23 | | - | |
| 20 | + | |
24 | 21 | | |
25 | 22 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | 23 | | |
31 | 24 | | |
32 | 25 | | |
| |||
62 | 55 | | |
63 | 56 | | |
64 | 57 | | |
65 | | - | |
66 | | - | |
| 58 | + | |
67 | 59 | | |
68 | 60 | | |
69 | 61 | | |
| |||
72 | 64 | | |
73 | 65 | | |
74 | 66 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | 67 | | |
80 | 68 | | |
81 | 69 | | |
| |||
172 | 160 | | |
173 | 161 | | |
174 | 162 | | |
| 163 | + | |
175 | 164 | | |
176 | 165 | | |
177 | 166 | | |
178 | 167 | | |
179 | 168 | | |
180 | 169 | | |
181 | 170 | | |
182 | | - | |
183 | | - | |
| 171 | + | |
184 | 172 | | |
185 | 173 | | |
186 | 174 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
64 | 63 | | |
65 | 64 | | |
66 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
72 | | - | |
| 73 | + | |
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
| |||
0 commit comments