{"action":"created","issue":{"url":"https://api.github.com/repos/cmgmyr/laravel-messenger/issues/161","repository_url":"https://api.github.com/repos/cmgmyr/laravel-messenger","labels_url":"https://api.github.com/repos/cmgmyr/laravel-messenger/issues/161/labels{/name}","comments_url":"https://api.github.com/repos/cmgmyr/laravel-messenger/issues/161/comments","events_url":"https://api.github.com/repos/cmgmyr/laravel-messenger/issues/161/events","html_url":"https://github.com/cmgmyr/laravel-messenger/issues/161","id":176171717,"number":161,"title":"Chat messages sent at the same time","user":{"login":"nikolaynesov","id":17743574,"avatar_url":"https://avatars.githubusercontent.com/u/17743574?v=3","gravatar_id":"","url":"https://api.github.com/users/nikolaynesov","html_url":"https://github.com/nikolaynesov","followers_url":"https://api.github.com/users/nikolaynesov/followers","following_url":"https://api.github.com/users/nikolaynesov/following{/other_user}","gists_url":"https://api.github.com/users/nikolaynesov/gists{/gist_id}","starred_url":"https://api.github.com/users/nikolaynesov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikolaynesov/subscriptions","organizations_url":"https://api.github.com/users/nikolaynesov/orgs","repos_url":"https://api.github.com/users/nikolaynesov/repos","events_url":"https://api.github.com/users/nikolaynesov/events{/privacy}","received_events_url":"https://api.github.com/users/nikolaynesov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-09-10T09:51:24Z","updated_at":"2016-09-10T16:35:56Z","closed_at":null,"body":"Hi guys,\r\n\r\nI am developing a **chat app** based on this package. The thing I am worried about is if 2 users in the same chatroom(thread) send **1 message at exactly the same time**, the same second. So bearing this in mind there are 3 questions:\r\n1) Should I use a **milliseconds timestamp** for messages as an additional column?\r\n2) Should I add a **unique index** on this _new column_ and _thread_id_?\r\n3) @cmgmyr If all these makes sense to you, are you going to include it to the package in case I make a pull request to update the migration? "},"comment":{"url":"https://api.github.com/repos/cmgmyr/laravel-messenger/issues/comments/246121490","html_url":"https://github.com/cmgmyr/laravel-messenger/issues/161#issuecomment-246121490","issue_url":"https://api.github.com/repos/cmgmyr/laravel-messenger/issues/161","id":246121490,"user":{"login":"a-komarev","id":1849174,"avatar_url":"https://avatars.githubusercontent.com/u/1849174?v=3","gravatar_id":"","url":"https://api.github.com/users/a-komarev","html_url":"https://github.com/a-komarev","followers_url":"https://api.github.com/users/a-komarev/followers","following_url":"https://api.github.com/users/a-komarev/following{/other_user}","gists_url":"https://api.github.com/users/a-komarev/gists{/gist_id}","starred_url":"https://api.github.com/users/a-komarev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/a-komarev/subscriptions","organizations_url":"https://api.github.com/users/a-komarev/orgs","repos_url":"https://api.github.com/users/a-komarev/repos","events_url":"https://api.github.com/users/a-komarev/events{/privacy}","received_events_url":"https://api.github.com/users/a-komarev/received_events","type":"User","site_admin":false},"created_at":"2016-09-10T16:35:56Z","updated_at":"2016-09-10T16:35:56Z","body":"Take a look at [Fractional seconds in MySQL](http://dev.mysql.com/doc/refman/5.7/en/fractional-seconds.html). But I'm not sure this implemented in all other databases.\r\n\r\nIf you will add separate column for milliseconds and they will be unique then you'll need to add 1 extra digit from 0 to 9 on the end which will allow you to have 10 concurrent messages in one millisecond, this should be enough.\r\n\r\nFirst of all you will need to find is there any records in such second + milliseconds exists but ignores latest digit, if yes - take latest digit, increments it and add a new record.\r\n\r\nBut there is one issue with all this behavior - performance. If you afraid of a lot of concurrent requests and will have a unique index - your should take into account that hardware requirements will be increased significantly because Unique index slows down all write requests and chats are mostly doing write requests, not read."}}
{"actor":{"display_login":"a-komarev"}}