JSONB Internals and GIN Indexing in PostgreSQL

Test your knowledge on how semi-structured data is stored, queried, and optimized using Generalized Inverted Indexes in Postgres.

Sample Questions

  1. What is the primary difference between the 'json' and 'jsonb' data types in PostgreSQL?

    • 'json' is stored as a plain text copy while 'jsonb' is stored in a decomposed binary format.
    • 'jsonb' is stored as a plain text copy while 'json' is stored in a decomposed binary format.
    • 'json' supports GIN indexing while 'jsonb' does not.
    • 'jsonb' preserves whitespace and key order while 'json' does not.
  2. Which GIN operator class is the default for JSONB columns in PostgreSQL?

    • jsonb_path_ops
    • jsonb_ops
    • jsonb_gin_ops
    • jsonb_value_ops
  3. What happens to duplicate keys when a JSON document is converted to 'jsonb'?

    • An error is thrown.
    • All values for the duplicate key are kept as an array.
    • Only the last value encountered is kept.
    • Only the first value encountered is kept.