PostgREST / postgrest-docs

This repo is archived and will be merged into postgrest/postgrest soon.
http://postgrest.org
MIT License
365 stars 164 forks source link

Add messagepack return type #696

Open saolof opened 1 year ago

saolof commented 1 year ago

Messagepack is a json-isomorphic binary serialization format that is becoming fairly widely supported and which supports fast streaming serialization/deserialization. It would be neat to have it as a return format. Both in JSON like form, and in a header + stream of tuples form for returning large numerical data sets like timeseries.

steve-chavez commented 1 year ago

msgpack was discussed here before: https://github.com/PostgREST/postgrest/issues/1548

https://github.com/PostgREST/postgrest/pull/1582 is still looking like the way forward

wolfgangwalther commented 1 year ago

Even with better content negotiation, we'd still need a way to convert to and from msgpack. Is there a postgres extension to do it?

steve-chavez commented 1 year ago

Yes, there's https://github.com/patriksimek/msgpack-postgres

wolfgangwalther commented 1 year ago

Yes, there's https://github.com/patriksimek/msgpack-postgres

Right, I'm just not sure whether an implementation written in plpgsql will be helpful in terms of performance... which seems to be the primary use-case for to request msgpack data in the first place.

wolfgangwalther commented 10 months ago

Is this now possible from PostgREST-side? I think it is, right? @steve-chavez

steve-chavez commented 10 months ago

Yeah, should be possible like:

create domain "application/x-msgpack" as bytea;

create or replace function hello() returns "application/x-msgpack" as $$
  select msgpack_encode('{"hello": "world"}'::jsonb);
$$ language sql;

Using the extension https://github.com/patriksimek/msgpack-postgres.