pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christian Weyer <christian.weyer@thinktecture.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Josh Berkus <josh@agliodbs.com>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: Unexpected (bad) performance when querying indexed JSONB column
Date: Mon, 2 Feb 2015 06:31:24 +0000
Message-ID: <A191183A-AE61-40B7-84C5-355B7A429086@thinktecture.com> (raw)
In-Reply-To: <4791.1422829257@sss.pgh.pa.us>
References: <7F9BEAD7-C190-4E21-8240-04687FA88435@thinktecture.com>
	<WM!3b9b688279bfaf852b09eb38e12d59633671a1b1dacc67e4f7be92553c116d3655cd62355ebe242eb4ae45275d2a5848!@asav-2.01.com>
	<54CE954F.7070904@agliodbs.com>
	<BC4E7C7F-86CB-441A-ABCE-6E0837AA1B65@thinktecture.com>
	<4791.1422829257@sss.pgh.pa.us>
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>

>>"Bitmap Heap Scan on articles  (cost=16.25..135.64 rows=33 width=427) 
>> (actual time=6.425..43.603 rows=18584 loops=1)"
>> "  Recheck Cond: (data @> ‘{"locked": true}'::jsonb)"
>> "  Heap Blocks: exact=1496"
>> "  Buffers: shared hit=1504"
>> "  ->  Bitmap Index Scan on idx_data  (cost=0.00..16.24 rows=33 
>>width=0) 
>> (actual time=6.090..6.090 rows=18584 loops=1)"
>> "        Index Cond: (data @> ‘{"locked": true}'::jsonb)"
>> "        Buffers: shared hit=8"
>> "Planning time: 0.348 ms"
>> "Execution time: 47.788 ms"
>
>So that's showing a runtime of 48 ms, not 900.  For retrieving 18584
>rows, doesn't sound that bad to me.
>
>(If the planner had had a better rowcount estimate, it'd likely have
>not bothered with the index at all but just done a seqscan.  This is
>a consequence of the lack of any very useful stats for JSONB columns,
>which is something we hope to address soon; but it's not done in 9.4
>and likely won't be in 9.5 either ...)
>
>			regards, tom lane

Thanks for your insights.
This greatly helped.

-C.


-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance


view thread (6+ messages)

Message-ID: <A191183A-AE61-40B7-84C5-355B7A429086@thinktecture.com>
Permalink:  ../A191183A-AE61-40B7-84C5-355B7A429086@thinktecture.com/
Also on:    postgresql.org/message-id/A191183A-AE61-40B7-84C5-355B7A429086@thinktecture.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: christian.weyer@thinktecture.com, tgl@sss.pgh.pa.us, josh@agliodbs.com
  Subject: Re: Unexpected (bad) performance when querying indexed JSONB column
  In-Reply-To: <A191183A-AE61-40B7-84C5-355B7A429086@thinktecture.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox