I am generating "hard to guess" URL by:
import uuid
url = uuid.uuid4()
URL is stored in Postgres database in field with ordinary index (for quick searching). Datatype of field is uuid: https://www.postgresql.org/docs/9.1/datatype-uuid.html
Another possibility for creating "hard to guess" URL is use secrets
module and store it in some Postgres string datatype:
import secrets
url = secrets.token_urlsafe()
What is better for quick searching in database and for safety of random generated url?
Thanks