Replace search and insert by insert and catch when creating short URLs #2134
Replies: 1 comment 6 replies
-
Ignore this. See the comments below |
Beta Was this translation helpful? Give feedback.
-
Ignore this. See the comments below |
Beta Was this translation helpful? Give feedback.
-
Today, Shlink will first find and then insert the shorturl in the db.
It would be interesting to compare the performance between this approach and trying to create and catch the cases where it fails and retry with a new short url. Given the odds are minimal that the short url is taken, I'd say the first query is useless in 99+% of the cases.
The unique index on short code + domain already exists, so an insert should fail when trying to introduce a duplicate.
Happy to explore this and benchmark, when I have some time that is :D
Beta Was this translation helpful? Give feedback.
All reactions