From: | "Richard Teviotdale" <richard(at)satcomresources(dot)com> |
---|---|
To: | <pgsql-general(at)postgresql(dot)org> |
Subject: | SERIAL or INT8 / Unique BLOB's |
Date: | 2002-01-02 23:47:16 |
Message-ID: | 00b001c193e7$cef5d3b0$8200a8c0@THEBOX |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Using SERIAL or INT8
I have been using SERIAL a great deal when creating table primary keys.
The type of integer that this creates is an INT4, but I noticed that there is a larger INT8 available.
Would it be advisable to create a sequence manually and use the INT8 if the table size might be expected to grow beyond the 2 billion limit imposed by a INT4 (INTEGER) field type?
Unique BLOB's
I want to allow users to put blob's into a database. But I would like the database to recognise when a user is tying to insert a file that is identical to an existing file, as opposed to duplicating the blob. Either way I have to record the oid of the blob in a table so I can "locate" it later. I call this table blob_oid.
My plan is:
Add a field ( blob_md5 VARCHAR(32) ) to the blob_oid table and make a UNIQUE INDEX on this field to prevent duplicate values.
Before adding any blobs do a md5sum of the file and try inserting this value into blob_md5. If the file already exists we should get an error because it would have the same md5sum, otherwise upload the blob and update the blob_oid record created in the previous step.
I think this would work, but perhaps there is a better way?
From | Date | Subject | |
---|---|---|---|
Next Message | Nate Haggard | 2002-01-03 00:28:51 | copy from ??? |
Previous Message | Tom Lane | 2002-01-02 22:20:12 | Re: tuplesort error from create index (?) |