Re: Returning JSON or JSONB

From: Andreas Kretschmer <akretschmer(at)spamfence(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Returning JSON or JSONB
Date: 2015-10-20 08:04:55
Message-ID: 20151020080455.GA8734@tux
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dane Foster <studdugie(at)gmail(dot)com> wrote:

> Hello,
>
> I was wondering when returning JSON data from a PostgreSQL function for
> consumption by clients (e.g., PHP or Lua) does it make any difference to
> declare the function's return type as JSON or JSONB?

JSONB is only for internal storage, for external representation you need
JSON.

> Now that I've actually written the question down it occurs to me that what I
> really want to know is which data type (JSON or JSONB or maybe TEXT) has the
> lowest overhead in terms of transformation and transmission at the PostgreSQL
> protocol level.

If you are returning JSON, so is JSON the best choice.

Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly." (unknown)
Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Birta Levente 2015-10-20 08:14:40 RAID and SSD configuration question
Previous Message Josip Rodin 2015-10-20 07:22:27 Re: ERROR: tablespace "archive2" is not empty