When you insert you need to check whether there is any row in the table.
Don't want to add a separate query to check first experience with the database, but I assume that it will increase the load.
Suggested that it is possible to use a composite unique key, but can't understand the documentationINSERT ON DUPLICATE KEY UPDATE
INSERT INTO dialogs (dialog_id, user_id) VALUES (1, 101)
how to modify that checked whether the string dialog_id=1 and user_id=101?
Maybe I do not at all, tell me please, who knows how to be in this situation?