Loaddata and Business Key Length

When using the api /loaddata command, you may get the following error: 

Specified key was too long; max key length is 3072 bytes

This error message relates to business keys. The loaddata command assumes that each key can have up to 255 characters. When there are multiple business keys, it will create a temp table with a column that is a concatenation of those keys. Then it may happen that their length will exceed the limit 

Using the maxJoinFieldsLenghts parameter you can tell loaddata that it is not needed to reserve 255 chars; instead you put there the real lengths (based on your knowledge of the data being loaded). Using this parameter will save a lot of space.

​​​​​{....
"maxJoinFieldsLengths": [
  {​​​​​​​​"joinField": "sku", "maxLength": 3}​​​​​​​​,
  {​​​​​​​​"joinField": "name", "maxLength": 4}​​​​​​​​,
  {​​​​​​​​"joinField": "attribute1", "maxLength": 1}​​​​​​​​,
  {​​​​​​​​"joinField": "attribute2", "maxLength": 1}​​​​​​​​,
  {​​​​​​​​"joinField": "attribute3", "maxLength": 1}​​​​​​​​,
  {​​​​​​​​"joinField": "attribute4", "maxLength": 1}​​​​​​​​,
  {​​​​​​​​"joinField": "attribute5", "maxLength": 3}​​​​​​​​
  ]
...}​​​​​​​​

See also: