Reputation: 3401
I want to shorten mongo _id for better use in urls. I found this similar question:How can one shorten mongo ids for better use in URLs? which I don't think the best answer is a good enough one.
I worked out my own simple way:
db.coll.find().limit(1).skip(:id-1);
Is this a good way? Will this way seriously affect the performance compared with directly find by mongoid?
Upvotes: 0
Views: 1196
Reputation: 4520
Using skip() to try and duplicate some form of auto incrementing ids is a bad idea, if you look at the Advanced Queries documentation it's noted that skip() can be very costly. The solutions outlined in the original question are generally going to be your best bet for something that's efficient.
Upvotes: 1