a custom datatype or fdw in postgresql seems interesting to me.

There's one, but with some limitations (For example - only vectors of up to 1024 dimensions)

https://github.com/pgvector/pgvector