I'm storing images on the Bytea data type of Postgresql, I do understand that this is not recommend, but I do think the benefits of having the images organized out-wights the disadvantages for my use. The issue I'm facing is that I want to make sure only unique images get inserted, However when I create a unique constraint, I get the following error
ERROR: index row requires 28120 bytes, maximum size is 8191
How can I check for uniqueness when inserting images into the bytea data type of Postgresql?
Create a unique index on a digest:
CREATE UNIQUE INDEX idx_image_hash ON images (digest(img, 'sha1'));
This assumes you have the pgcrypto extension installed:
CREATE EXTENSION pgcrypto;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With