Hello Liam,
 
- Have you checked logs to see what happened in the morning?
- Is the log_lock_waits parameter enabled?
- What postgres version do you use?
- Is 43 min 11 seconds total duration or max duration?
 
Best regards.
Samed YILDIRIM
 
 
 
03.12.2021, 14:24, "liam saffioti" <liam.saffiotti@gmail.com>:
Hello Team,
 
I have a problem with a query that consumes a long time. 
The query' execution plan is :
 
 
EXPLAIN ANALYZE SELECT x."HistoryId", x."SlaDefinition" FROM "T_CMN_SLAHISTORY" AS x WHERE x."DefinitionId" = '302';
                                                                        QUERY PLAN                                                                        
-----------------------------------------------------------------------------------------------------------------------------------------------------------
 Bitmap Heap Scan on "T_CMN_SLAHISTORY" x  (cost=2144.77..35086.42 rows=139012 width=8) (actual time=58.806..116.874 rows=135498 loops=1)
   Recheck Cond: ("DefinitionId" = 302)
   Heap Blocks: exact=2175
   ->  Bitmap Index Scan on "Index-20180712-192739"  (cost=0.00..2110.02 rows=139012 width=0) (actual time=57.043..57.045 rows=135498 loops=1)
         Index Cond: ("DefinitionId" = 302)
 Planning Time: 11.132 ms
 Execution Time: 120.320 ms
 
 
 
But, the query execution time was 43min 11seconds in the morning in pgbadger report. I don't understand why the query is taking so long. Can you guide me?
 
Thank you so much.