Is it possible to optimize the structure of a Mysql table using sorting?

Hi all.
I need to store a large amount of information about the relationships between objects. For example объект1 -> объект65
One object can have many relationships with other objects (in other words we have a directed graph).
I want to store this in a table with keys obj1 / obj2
So something like

объект1 -> объект65
объект1 -> объект100
objet2 -> объект65
объект1 -> objet2
объект5 -> объект13

Will look at the first column is not unique, and duplicate values.
SO: is There a DBMS (mysql or PostgreSQL) tools more advanced than simple exercise key and is there any command PRELIMINARY sorting of the values in the table by the first column for faster searching for her in the process??

PS: May You suggest other ways of graph storage and RDF triples in database. While the relationship between the objects only of the type "see also" and "includes", but in the future it is possible expansion to full-fledged RDF.
June 10th 19 at 15:38
3 answers
June 10th 19 at 15:40
mysql/innodb always clustered on the primary key. I.e. the data is physically ordered in the order specified primary key. The actual data lie in the leaves of the primary key.

postgresql is able to command cluster which disposable rewrites the table in the order specified index (plus attention to a table lock for the duration of the rebuild). In the further work of writing queries-clustering the data does not support.

Does the clustering make sense for your problem - not sure. It is necessary to look the disk and the amount of hot data in relation to buffer memory.

But for graphs it's probably better to take a graph and not a relational DBMS.
Thanks for the tip!
CLUSTER - this is what you need. Given the fact that the table I have rarely changed.
related links : - nikita.Stracke commented on June 10th 19 at 15:43
June 10th 19 at 15:42
For fast search in a relational database designed indexes. The table itself sort of makes no sense, why would you completely rewrite it when you add new values. Make a composite unique index (obj1, obj2) and obj1 search, it will be used for acceleration.
June 10th 19 at 15:44
all well said. The database may physically store the data not in the same order as their displays in the table by default, and sorting will not give You anything. To speed up data retrieval indexes are there. Make your connection a composite key and indexing the whole thing.

Find more questions by tags MySQL