I'm converting title as product url which i will then insert into product table in database. eg. "Fast computer whit awesome monitor" would be "fast-computer-whit-awesome-monitor".
If users are adding same title for products, we'll add end of url some random numbers eg."fast-computer-whit-awesome-monitor-86553". When generating that random number, how do I check that there is not url whit same random number in place?
The same way you would check whether or not you needed to generate the random number for duplicate titles in the first case. Make it a function, 'check_duplicate()' and run it once to see if the number needs to be generated, and again to make sure the generated number isn't already in there.
Or take a page from WordPress and generate it in numerical order. Find the last title, 'some-duplicate-title-2' and add 1 to it.