Tuesday, October 15, 2013

Very efficient JSON in PostgreSQL

From this old approach:

  select array_to_json(array_agg(row_to_json(t))) 
  from (select firstname, lastname, favorite_number from person) t;


To this new one:
  select json_agg(t)
  from (select firstname, lastname, favorite_number from person) t;

No comments:

Post a Comment