Re: JSONB index not in use, but is TOAST the real cause of slow query? - Mailing list pgsql-general

From Jeff Janes
Subject Re: JSONB index not in use, but is TOAST the real cause of slow query?
Date
Msg-id CAMkU=1yuOCa8R8fw6hE0JbnRY8RWr+aKGre6UvaPBV0k6Mi=fg@mail.gmail.com
Whole thread Raw
In response to JSONB index not in use, but is TOAST the real cause of slow query?  (Shaheed Haque <shaheedhaque@gmail.com>)
List pgsql-general
On Sat, May 28, 2022 at 1:54 PM Shaheed Haque <shaheedhaque@gmail.com> wrote:
 

And how can I understand the dreadful amount of
time (of course, this is just on my dev machine, but still...)? Is
there a way to see/tweak what TOAST costs or indeed to confirm if it
is even in use?

Turn on track_io_timing, and then do explain (analyse, buffers).  This won't distinguish TOAST from main table IO, but will at least confirm if a large amount of IO is happening and how long it is taking.  

You can look at pg_statio_user_tables before the after the query to distinguish TOAST, but this won't give you the timing, just the block counts.  And the counts might also get incremented by concurrent users, so on a busy system it is hard to interpret.

Are these queries fast upon repeat execution?  A few meg time less than 1000 it just not that much with modern hardware, you should be able to just cache it in RAM.

Cheers,

Jeff

pgsql-general by date:

Previous
From: Shaheed Haque
Date:
Subject: Re: Is it possible to index "deep" into a JSONB column?
Next
From: Jeff Janes
Date:
Subject: Re: autovacuum on primary blocking queries on replica?