I'm using Postgres as my database with my application written in Django using it's ORM API. I'm creating an extremely high quality random string of length 22 + prefix (24 total) to use as a PK for my objects like this...
This is my key generation?
def make_Key(app_prefix):
return app_prefix + base64.b64encode(uuid.uuid4().bytes).decode("utf-8").rstrip('=\n').replace('/', '_').replace(
"+", "-")
My question is, will I have issues with indexing or speed later on doing this? I'm NOT after a int vs UUID answer, UUIDs have more pros then cons for my system. What I need to know is if I can make this more "indexable", or if there is a better solution in Django for this (maybe there is nothing wrong with how I have done it?).
My model
class Image(models.Model):
id = models.CharField(primary_key=True, max_length=28, unique=True,
default=get_key,editable=False)
etc