Unexpected (bad) performance when querying indexed JSONB column

From: Christian Weyer <christian(dot)weyer(at)thinktecture(dot)com>
To: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Unexpected (bad) performance when querying indexed JSONB column
Date: 2015-01-31 16:00:42
Message-ID: 0776A628-6450-4E46-B059-1BAD56BA50AE@thinktecture.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Hi all,

The pg version in question is the latest 9.4., running on Windows.

For testing out the NoSQL features of pg I have a simple table called ‘articles’ with a column called ‘data’.

There is an index on ‘data’ like this:
CREATE INDEX idx_data ON articles USING gin (data jsonb_path_ops);

The current test data set has 32570 entires of JSON docs like this:
{
"title": "Foo Bar",
"locked": true,
"valid_until": "2049-12-31T00:00:00",
"art_number": 12345678,
"valid_since": "2013-10-05T00:00:00",
"number_valid": false,
"combinations": {
"var1": "4711",
"var2": "4711",
"var3": "0815",
"int_art_number": "000001"
}
}

Nothing too complex, I think.

When I run a simple query:
SELECT data #>> ‘{"title"}'
FROM articles
WHERE data @> '{ “locked" : true }';

Reproducingly, it takes approx. 900ms to get the results back.
Honestly, I was expecting a much faster query.

Any opinions on this?

Thanks,
-C.

Browse pgsql-performance by date

  From Date Subject
Next Message Christian Weyer 2015-01-31 19:02:45 Re: Unexpected (bad) performance when querying indexed JSONB column
Previous Message Pavel Stehule 2015-01-31 06:28:08 Re: Query performance