How would you index JSONB searches in PostgreSQL?
You have a large PostgreSQL table called events with a payload JSONB column. Some queries find events containing a particular JSON fragment: WHERE payload @> '{"source":"mobile"}'. Others extract a field's value and compare it with a string: WHERE payload->>'country' = 'DE'. Which indexes would you recommend for these queries? Explain how GIN and B-tree differ for these conditions. What limitations and costs would you consider?
ExplainIndexesMiddleBackendAnalystData EngineerQA