Is there a better data type to be using to store a zlib compressed string in Postgresql?
Asked
Active
Viewed 3,033 times
5
-
For PostgreSQL automatic compression (by TOAST), see http://stackoverflow.com/q/3801416/287948 – Peter Krauss May 07 '12 at 10:33
2 Answers
8
Use bytea "The bytea data type allows storage of binary strings"
-
Interesting. Any idea what this would be in Django? Meaning what Django field type would yield this type in Postgres? – Rhubarb Jun 02 '10 at 13:31
-
Apparently django doesn't support bytea directly - see http://stackoverflow.com/questions/517349/binaryfields-in-django-models , You could e.g. base64 encode your data and continue to use a text field - though you'd lose some of the benefit of compression – nos Jun 02 '10 at 13:41
-
See [`BinaryField`](https://docs.djangoproject.com/en/1.11/ref/models/fields/#binaryfield). – Phil Krylov Aug 09 '17 at 12:29
4
-
2Citing sources last updated 8 years ago when up to date and authoritative sources exist is probably more confusing than helpful. – Milen A. Radev Jun 02 '10 at 13:35
-
`bytea` , as by other answer, is what corresponds, in Postgresql, to the BLOB concept. – leonbloy Jun 02 '10 at 15:55