Create a PK for a catalog w/o PK I have a catalog-like huge table at my client's infrastructure, that I pull into my db: no pk, and I wasn't able to find a way to create a pk from the existing columns - the table has no restrictions on duplicates etc. Also the row-number approach does not work, as the source is being overwritten with truncate daily, and it will create a wrong data-structure.

The only solution I came up with is a creation of all-field-pk, which would solve this particular issue, but it would introduce the unsolvable performance issue.

So the actual question is:
How to create a pk for a table with such data?

UPD: I really look for a solution, that generates the pk from the data, not row number etc.
You wrote: I really look for a solution, that generates the pk from the data, not row number etc.  - Would calculating a checksum and using it as a PK value be suitable for you?

Consider the following: a table with over 9 million rows, loads of duplicates, no primary key (this is just what I imagine your raw data set looks like ... I've used MySQL 5.7).  If we concatenate all values of a row, and have the SHA1 sum calculated, we get a rather good "fingerprint" of each row (yes, I know that SHA1 collisions have been found.  However, maybe this algorithm will be good enough to satisfy your requirements. Article on SHA1 collisions: https://www.theregister.co.uk/2017/02/23/google_first_sha1_collision/). 

-- small table
create table t (
  n1 int
, v1 varchar(32)
, n2 int
, v2 varchar(32)
, n3 int
);

-- 25 rows, 23 unique rows
insert into t values
(1,'aaa', 1000, 'ttttt', 1111),
(1,'bbb', 1001, 'ttttt', 2222),
(1,'ccc', 1000, 'ttttt', 3333),
(1,'ddd', 1001, 'ttttt', 1111),
(1,'eee', 1000, 'ttttt', 2222),
(1,'aaa', 1001, 'ttttt', 3333), -- duplicate
(1,'eee', 1000, 'ttttt', 4444),
(1,'aaa', 1001, 'ttttt', 3333), -- duplicate
(1,'eee', 1000, 'ttttt', 5555),
(1,'aaa', 1001, 'ttttt', 3333), -- duplicate
(1,'bbb', 1000, 'x', 1111),
(1,'aaa', 1000, 'xx', 1111),
(1,'bbb', 1001, 'xxx', 2222),
(1,'ccc', 1000, 'xxxx', 3333),
(1,'ddd', 1001, 'xxxxx', 1111),
(1,'eee', 1000, 'y', 2222),
(1,'aaa', 1001, 'yy', 3333),
(1,'eee', 1000, 'yyy', 4444),
(1,'aaa', 1001, 'yyyy', 3333),
(1,'eee', 1000, 'yyyyy', 5555),
(1,'aaa', 1001, 'z', 3333),
(1,'bbb', 1000, 'zz', 1111),
(1,'aaa', 1001, 'zzz', 3333),
(1,'bbb', 1000, 'zzzz', 1111),
(1,'aaa', 1001, 'zzzzz', 3333);


Use the small table to create a bigger table -> we get the actual test data.

create table tbig
as
select t1.n1, t1.v1, t1.n2, t1.v2, t1.n3
from t t1, t t2, t t3, t t4, t t5;

-- output:
Query OK, 9765625 rows affected (24.23 sec)
Records: 9765625  Duplicates: 0  Warnings: 0


Create a table that has an additional column, containing the SHA1 for each row.

create table tbig_sha1
as 
select 
  sha1(concat(n1, v1, n2, v2, n3)) sha1
, n1, v1, n2, v2, n3
from tbig; 

-- output:
Query OK, 9765625 rows affected (38.22 sec)
Records: 9765625  Duplicates: 0  Warnings: 0


Detect and eliminate duplicates (this may need: SET sql_mode = '';).

create table t_sha1
as
select sha1, n1, v1, n2, v2, n3  
from tbig_sha1 
group by sha1 
order by sha1;

-- output:
Query OK, 23 rows affected (18.86 sec)
Records: 23  Duplicates: 0  Warnings: 0


Final result:

mysql&gt; select * from t_sha1;
+------------------------------------------+------+------+------+-------+------+
| sha1                                     | n1   | v1   | n2   | v2    | n3   |
+------------------------------------------+------+------+------+-------+------+
| 0401e846eac37342dd8de769f3385d3090b9c47c |    1 | aaa  | 1000 | xx    | 1111 |
| 09c837f5a4dfa77dc25e37151ba279410ab82cd4 |    1 | aaa  | 1001 | yy    | 3333 |
| 2cde8e392e5f20c7735add5cc073466bbee77830 |    1 | aaa  | 1001 | z     | 3333 |
| 479de10da975efa02a407709d42bf6bc82c08a5e |    1 | bbb  | 1001 | ttttt | 2222 |
| 59e7b2fd58dcd2047289daf41ed165a19f2d5caf |    1 | ccc  | 1000 | xxxx  | 3333 |
| 6222c427cb2c014f982a25a2b684d3c989975164 |    1 | aaa  | 1001 | zzzzz | 3333 |
| 65715bccb92e92b5e95df308bc30aa1e70ec308c |    1 | aaa  | 1001 | zzz   | 3333 |
| 726a867623269a178fa002287448278038e92140 |    1 | eee  | 1000 | yyyyy | 5555 |
| 750054b78741acab58ba474be62ce2bcd9976ed8 |    1 | eee  | 1000 | y     | 2222 |
| 87c720132853afa3ce728caa425482a37038e617 |    1 | aaa  | 1000 | ttttt | 1111 |
| 8bcc29485d571c865de8f62d779dd1b474ddc9de |    1 | bbb  | 1000 | zz    | 1111 |
| 9df67a1d57fa702e4ce2f903ae312153aee09400 |    1 | bbb  | 1001 | xxx   | 2222 |
| a725ff1ae11a9b468392450ef1bffb28991c3b8d |    1 | bbb  | 1000 | zzzz  | 1111 |
| a8b3d416da6c222572ce63dd4ff3212a31a8b339 |    1 | eee  | 1000 | ttttt | 2222 |
| b232dd78cf258899c6df9535013c3fff2b1a835c |    1 | ddd  | 1001 | ttttt | 1111 |
| bb7e24d2df9bc71df1596a081576324ae214273a |    1 | eee  | 1000 | ttttt | 5555 |
| c062cca2e1b3d6d72c4c8420d4810115d5107136 |    1 | aaa  | 1001 | ttttt | 3333 |
| ce210358b4f24e767be6ca223cfe22d51abd563f |    1 | eee  | 1000 | ttttt | 4444 |
| e9cf971e943bcb885bd8ec10a15cb7f1325ad9f7 |    1 | aaa  | 1001 | yyyy  | 3333 |
| f57524ca9bd6a64e155b35f660a0170cdf59e518 |    1 | bbb  | 1000 | x     | 1111 |
| f7e905f522eeb34e57e87ba9e2b5e298fbe00246 |    1 | ccc  | 1000 | ttttt | 3333 |
| f8b900611fdba9592fd28417614ef93fb59dbe6f |    1 | eee  | 1000 | yyy   | 4444 |
| fe64ffc09e699b927f9e01ad790662e2de1026f5 |    1 | ddd  | 1001 | xxxxx | 1111 |
+------------------------------------------+------+------+------+-------+------+
23 rows in set (0.00 sec)


Then, we can use the "sha1" column as "PK".  Notice that we only have 23 rows now (the duplicates have been removed).

alter table t_sha1
add constraint pksha1
primary key (sha1);