[MDEV-18061] Silent varchar(255) key size truncation to 250 Created: 2018-12-22 Updated: 2019-01-22 Resolved: 2019-01-22 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Definition - Create Table |
| Affects Version/s: | 10.3 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Olaf van der Spek | Assignee: | Sergei Golubchik |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Update: The warning / error also seems to be inconsistent, in alter table convert charset it appears to be an error.
|
| Comments |
| Comment by Sergei Golubchik [ 2019-01-22 ] |
|
This is expected behavior. Physical key limitation is (and was for a long time) a 1000 bytes. You use utfmb4 character set, it means four bytes per character. Thus you get 250 characters. But it's nothing to be concerned of. An index is just a optimization, helping to resolve queries faster. This is why the server allows itself to truncate the index as necessary. In your case you would only notice a difference in performance if you store a huge amount of strings that are completely identical in the first 250 characters and only differ in the last five. Note, that unique index is a constraint, not just an optimization. The server will never truncate a unique index automatically, because it would've affected the correctness of the data. |
| Comment by Olaf van der Spek [ 2019-01-22 ] |
|
I certainly wasn't expecting this.. > Note, that unique index is a constraint, not just an optimization. I have such unique constraints on my varchar(255) columns.. I'm sure others have too. What should we do? |
| Comment by Sergei Golubchik [ 2019-01-22 ] |
|
Currently they'll abort CREATE TABLE with an error. There is a task to fix it For older versions... You can reduce the column length to 250, or switch to utf8 (3 bytes per char). Or use InnoDB it has larger limits, if I'm not mistaken. |