I have a data set that needs to be looked up by RSA public keys. These keys are 392 text characters long.
What is the best way to make that a primary and/or unique key?
Should it be a BYTEA field?
Is it too long for a primary key? Should I store a shorter hashed version of it to index on and filter by first before checking for an exact match?
Best Answer
I would say store them as
bytea
, but not for that reason. Simply becausepg_crypto
expects the keys as bytea. That establishes a convention. They likely have good reason for it: it seems intuitively faster.Also there is no reason to store them as a
PRIMARY KEY
. You can sanely just store them in an indexed field.