efcore.pg icon indicating copy to clipboard operation
efcore.pg copied to clipboard

Migrations: add support for specifying column storage

Open springy76 opened this issue 3 years ago • 1 comments

I have to store precompressed data and it is important to not waste CPU on compression attempts which enlarge the data.

I tried tbl.Propery(t => t.ByteArray).HasColumnType("bytea storage external") and tbl.Propery(t => t.ByteArray).UseCompressionMethod("external") // just worth a try, I know there is only pglz and lz4 tbl.Propery(t => t.ByteArray).UseCompressionMethod("none") // just worth a try, I know there is only pglz and lz4

BTW the documentation for UseCompressionMethod() isn't very helpful at all

springy76 avatar Jul 05 '22 15:07 springy76

@springy76 as far as I know, changing the storage of column is done via ALTER TABLE:

ALTER TABLE data ALTER COLUMN name SET STORAGE EXTERNAL;

It cannot be specified after the type name, nor is it related to the compression method.

There's no current support for having EF Core manage that for you, but it's trivial to use raw SQL in your migrations to add the ALTER TABLE.

Will keep this open to track adding support, though this is the first time anyone has ever mentioned it.

roji avatar Jul 11 '22 08:07 roji