Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 34857

JavaScript Object Notation (JSON) is an open, human and machine-readable standard that facilitates data interchange, and along with XML is the main format for data interchange used on the modern web.

2 votes
Accepted

Efficient way to compute unique values using a PostgreSQL GIN index

This can't be done. Of the two built-in GIN operators for indexing JSONB, one of them only stores hashed values, so you wouldn't be able to reverse them, and other one stores flattened keys, irrespec …
jjanes's user avatar
  • 41.3k
2 votes
Accepted

Are "column names" optimized in PostgreSQL JSONB jsonb_agg(*)?

Each column name, as a JSON key, is sent in full, multiple times. … If that is the highest cost you have to pay for gratuitous use of JSON, then consider yourself lucky. …
jjanes's user avatar
  • 41.3k
2 votes
Accepted

Postgres SELECT rows where JSON array contains "most" of values

(Changing from JSON to JSONB might speed it up slightly) …
jjanes's user avatar
  • 41.3k
4 votes
Accepted

Index on JSONB not improving query speed

Your JSON structure appears to be flat (based on one example), couldn't you just map those fields into real PostgreSQL columns? … Top level JSON attributes do not get the same kind of statistics on that as real columns do. …
jjanes's user avatar
  • 41.3k
1 vote
Accepted

How to filter rows based on a nested JSON array field?

But it also can't benefit from the gin index on the json column. …
jjanes's user avatar
  • 41.3k
4 votes

Slow access to JSONB column

I just wouldn't use JSON or JSONB for this purpose if I wanted speed. If you need to access a small number of keys, pulling them out into the table proper could help. …
jjanes's user avatar
  • 41.3k
1 vote

Update postgres json value by other attribute

You could keep your current UPDATE statement, but add WHERE data ? 'my-value' to it to avoid updating rows which have nothing you want to update. When v13 is released, you could use the new jsonb_set_ …
jjanes's user avatar
  • 41.3k
1 vote
Accepted

Transform/map json object array to primitive for GIN indexing

Assuming that that ship has sailed, I would at least transform it to a native PostgreSQL array, not a JSON(B) array, as that would give you better statistics estimates and so probably better execution …
jjanes's user avatar
  • 41.3k
0 votes
Accepted

Accessing nested array in json blob in PostgreSQL

Your example data and your example query do not fit together. There is no JSONB field named 'MMC' in the data, but there is in the query, for example. Assuming the query is the thing that is correct …
jjanes's user avatar
  • 41.3k
0 votes
Accepted

how to update PostgreSQL array of jsonb

You can use jsonpath (to be new in version 12) to extract elements of JSON arrays based on conditionals (rather than just based on the array index), but I don't see a way to either update the extracted …
jjanes's user avatar
  • 41.3k
1 vote

How to keep array fields in PostgreSQL jsonb

Convert the array to a text representation before storing it. It looks like you tried that, but you put the cast in the wrong place. SELECT (jsonb_build_object('location', ARRAY['world']::text))->>'l …
jjanes's user avatar
  • 41.3k
3 votes
Accepted

Did adding JSONB indexes bloat the database?

I don't think the archeological approach will be very useful here. There is just too much missing info and confounding variables. For example, people usually don't just add indexes for no reason. I …
jjanes's user avatar
  • 41.3k
3 votes

Trigram index on all values of a JSONB column

You can create a function which returns the data as a string: CREATE OR REPLACE FUNCTION public.jsonb_val_to_string(jsonb) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $function$ declare x text; BEG …
jjanes's user avatar
  • 41.3k
1 vote
Accepted

How to parameterize a Postgres JSON containment query with arrays of objects?

; But maybe you should be using some C++ library to build the JSON and pass it already formed down to PostgreSQL. … If you don't want to be dealing with JSON on the client side, you likely should not be using it on the db side either. …
jjanes's user avatar
  • 41.3k
2 votes
Accepted

Postgres serializable snapshot isolation for jsonb

level of separation, you would have to have a parent and child table, where the child table would be something like: (parent_id whatever, key text, value text, primary key (parent_id, key)) If your JSON
jjanes's user avatar
  • 41.3k

15 30 50 per page