Complete the code to create a GIN index on the JSONB column named 'data'.
CREATE INDEX idx_data ON my_table USING [1] (data);The GIN index type is used for indexing JSONB columns efficiently in PostgreSQL.
Complete the code to create a GIN index on the 'info' JSONB column with the jsonb_path_ops operator class.
CREATE INDEX idx_info ON users USING gin (info [1]);The jsonb_path_ops operator class creates a smaller and faster GIN index for existence queries on JSONB.
Fix the error in the index creation statement to correctly use GIN on the JSONB column 'attributes'.
CREATE INDEX idx_attr ON products USING gin (attributes [1]);The correct operator class for a general GIN index on JSONB is jsonb_ops. The others are invalid or for JSON, not JSONB.
Fill both blanks to create a GIN index on the JSONB column 'details' using the default operator class.
CREATE INDEX idx_details ON orders USING [1] (details [2]);
The index type must be gin and the operator class for JSONB default is jsonb_ops.
Fill all three blanks to create a GIN index on the JSONB column 'config' with the jsonb_path_ops operator class and a custom index name.
CREATE INDEX [1] ON settings USING [2] (config [3]);
The index name can be custom like idx_config_gin. The index type is gin and the operator class for optimized JSONB path queries is jsonb_path_ops.