[ 
https://issues.apache.org/jira/browse/CONNECTORS-678?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13641764#comment-13641764
 ] 

Karl Wright commented on CONNECTORS-678:
----------------------------------------

Erlend reports in actual use we're still getting lousy times.  The new code 
prints EXPLAIN ANALYZE so here's the output:

{code}
WARN 2013-04-25 14:23:37,175 (Stuffer thread) - Found a long-running query 
(62339 ms): [SELECT 
t0.id,t0.jobid,t0.dochash,t0.docid,t0.status,t0.failtime,t0.failcount,t0.priorityset
 FROM jobqueue t0  WHERE t0.status IN (?,?) AND t0.checkaction=? AND 
t0.checktime<=? AND EXISTS(SELECT 'x' FROM jobs t1 WHERE t1.status IN (?,?) AND 
t1.id=t0.jobid AND t1.priority=?) AND NOT EXISTS(SELECT 'x' FROM jobqueue t2 
WHERE t2.dochash=t0.dochash AND t2.status IN (?,?,?,?,?,?) AND 
t2.jobid!=t0.jobid) AND NOT EXISTS(SELECT 'x' FROM prereqevents t3,events t4 
WHERE t0.id=t3.owner AND t3.eventname=t4.name) ORDER BY t0.docpriority ASC 
LIMIT 100]
 WARN 2013-04-25 14:23:37,175 (Stuffer thread) -   Parameter 0: 'P'
 WARN 2013-04-25 14:23:37,175 (Stuffer thread) -   Parameter 1: 'G'
 WARN 2013-04-25 14:23:37,175 (Stuffer thread) -   Parameter 2: 'R'
 WARN 2013-04-25 14:23:37,175 (Stuffer thread) -   Parameter 3: '1366892554745'
 WARN 2013-04-25 14:23:37,175 (Stuffer thread) -   Parameter 4: 'A'
 WARN 2013-04-25 14:23:37,175 (Stuffer thread) -   Parameter 5: 'a'
 WARN 2013-04-25 14:23:37,175 (Stuffer thread) -   Parameter 6: '5'
 WARN 2013-04-25 14:23:37,175 (Stuffer thread) -   Parameter 7: 'A'
 WARN 2013-04-25 14:23:37,175 (Stuffer thread) -   Parameter 8: 'F'
 WARN 2013-04-25 14:23:37,175 (Stuffer thread) -   Parameter 9: 'a'
 WARN 2013-04-25 14:23:37,175 (Stuffer thread) -   Parameter 10: 'f'
 WARN 2013-04-25 14:23:37,175 (Stuffer thread) -   Parameter 11: 'D'
 WARN 2013-04-25 14:23:37,175 (Stuffer thread) -   Parameter 12: 'd'
 WARN 2013-04-25 14:32:33,766 (Stuffer thread) -  Plan: Limit 
(cost=9603.72..9603.72 rows=1 width=155) (actual time=536587.381..536587.586 
rows=100 loops=1)
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -  Plan:   ->  Sort 
(cost=9603.72..9603.72 rows=1 width=155) (actual time=536587.379..536587.449 
rows=100 loops=1)
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -  Plan:         Sort Key: 
t0.docpriority
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -  Plan:         Sort Method: 
top-N heapsort  Memory: 51kB
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -  Plan:         -> Nested Loop 
Anti Join  (cost=17.68..9603.71 rows=1 width=155) (actual 
time=1.565..536578.061 rows=1592 loops=1)
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -  Plan: Join Filter: (t2.jobid 
<> t0.jobid)
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -  Plan: ->  Nested Loop Semi 
Join  (cost=17.68..9595.09 rows=1 width=155) (actual time=1.551..536533.696 
rows=1592 loops=1)
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -  Plan:      Join Filter: 
(t0.jobid = t1.id)
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -  Plan:      ->  Nested Loop 
Anti Join  (cost=17.68..9593.04 rows=1 width=155) (actual 
time=1.541..536504.762 rows=1592 loops=1)
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -  Plan:            Join Filter: 
(t0.id = t3.owner)
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -  Plan:            ->  Bitmap 
Heap Scan on jobqueue t0  (cost=4.53..6.54 rows=1 width=155) (actual 
time=1.516..8.783 rows=1592 loops=1)
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -  Plan:                  
Recheck Cond: (status = ANY ('{P,G}'::bpchar[]))
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -  Plan:                  
Filter: ((checktime <= 1366892554745::bigint) AND (checkaction = 'R'::bpchar))
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -  Plan:                  ->  
Bitmap Index Scan on i1362584563122 (cost=0.00..4.53 rows=1 width=0) (actual 
time=1.375..1.375 rows=8931 loops=1)
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -  Plan:                        
Index Cond: (status = ANY ('{P,G}'::bpchar[]))
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -  Plan:            ->  Hash 
Join  (cost=13.15..7637.41 rows=231632 width=8) (actual time=336.989..336.989 
rows=0 loops=1592)
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -  Plan:                  Hash 
Cond: ((t3.eventname)::text = (t4.name)::text)
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -  Plan:                  ->  
Seq Scan on prereqevents t3  (cost=0.00..4439.32 rows=231632 width=37) (actual 
time=0.006..160.286 rows=231491 loops=1592)
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -  Plan:                  ->  
Hash  (cost=11.40..11.40 rows=140 width=516) (actual time=0.005..0.005 rows=0 
loops=1)
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -  Plan:                        
Buckets: 1024  Batches: 1  Memory Usage: 0kB
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -  Plan:                        
->  Seq Scan on events t4  (cost=0.00..11.40 rows=140 width=516) (actual 
time=0.003..0.003 rows=0 loops=1)
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -  Plan:      ->  Seq Scan on 
jobs t1  (cost=0.00..2.03 rows=2 width=8) (actual time=0.008..0.008 rows=1 
loops=1592)
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -  Plan:            Filter: 
((status = ANY ('{A,a}'::bpchar[])) AND (priority = 5::bigint))
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -  Plan: ->  Index Scan using 
i1362584563120 on jobqueue t2  (cost=0.00..4.30 rows=1 width=49) (actual 
time=0.020..0.020 rows=0 loops=1592)
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -  Plan:      Index Cond: 
((dochash)::text = (t0.dochash)::text)
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -  Plan:      Filter: (status = 
ANY ('{A,F,a,f,D,d}'::bpchar[]))
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -  Plan: Total runtime: 
536587.771 ms
 WARN 2013-04-25 14:32:33,767 (Stuffer thread) -
{code}

I'm reopening the ticket.

                
> Postgresql generating unusual and slow (76 second) plans for stuffer queries
> ----------------------------------------------------------------------------
>
>                 Key: CONNECTORS-678
>                 URL: https://issues.apache.org/jira/browse/CONNECTORS-678
>             Project: ManifoldCF
>          Issue Type: Bug
>          Components: Framework core
>    Affects Versions: ManifoldCF 1.1.1
>            Reporter: Karl Wright
>            Assignee: Karl Wright
>            Priority: Critical
>             Fix For: ManifoldCF 1.2
>
>
> Query plans like this seem to be taking place:
> {code}
>  WARN 2013-04-22 13:01:20,414 (Stuffer thread) -  Plan: Limit  
> (cost=9597.49..9597.49 rows=1 width=155)
>  WARN 2013-04-22 13:01:20,414 (Stuffer thread) -  Plan:   ->  Sort  
> (cost=9597.49..9597.49 rows=1 width=155)
>  WARN 2013-04-22 13:01:20,414 (Stuffer thread) -  Plan:         Sort Key: 
> t0.docpriority
>  WARN 2013-04-22 13:01:20,414 (Stuffer thread) -  Plan:         ->  Nested 
> Loop Anti Join  (cost=17.68..9597.48 rows=1 width=155)
>  WARN 2013-04-22 13:01:20,414 (Stuffer thread) -  Plan:               Join 
> Filter: (t2.jobid <> t0.jobid)
>  WARN 2013-04-22 13:01:20,414 (Stuffer thread) -  Plan:               ->  
> Nested Loop Semi Join  (cost=17.68..9588.87 rows=1 width=155)
>  WARN 2013-04-22 13:01:20,414 (Stuffer thread) -  Plan:                     
> Join Filter: (t0.jobid = t1.id)
>  WARN 2013-04-22 13:01:20,414 (Stuffer thread) -  Plan:                     
> ->  Nested Loop Anti Join  (cost=17.68..9586.81 rows=1 width=155)
>  WARN 2013-04-22 13:01:20,414 (Stuffer thread) -  Plan:                       
>     Join Filter: (t0.id = t3.owner)
>  WARN 2013-04-22 13:01:20,414 (Stuffer thread) -  Plan:                       
>     ->  Bitmap Heap Scan on jobqueue t0  (cost=4.53..6.54 rows=1 width=155)
>  WARN 2013-04-22 13:01:20,414 (Stuffer thread) -  Plan:                       
>           Recheck Cond: (status = ANY ('{P,G}'::bpchar[]))
>  WARN 2013-04-22 13:01:20,414 (Stuffer thread) -  Plan:                       
>           Filter: ((checktime <= 1366628406182::bigint) AND (checkaction = 
> 'R'::bpchar))
>  WARN 2013-04-22 13:01:20,414 (Stuffer thread) -  Plan:                       
>           ->  Bitmap Index Scan on i1362584563122  (cost=0.00..4.53 rows=1 
> width=0)
>  WARN 2013-04-22 13:01:20,414 (Stuffer thread) -  Plan:                       
>                 Index Cond: (status = ANY ('{P,G}'::bpchar[]))
>  WARN 2013-04-22 13:01:20,414 (Stuffer thread) -  Plan:                       
>     ->  Hash Join  (cost=13.15..7635.56 rows=231554 width=8)
>  WARN 2013-04-22 13:01:20,414 (Stuffer thread) -  Plan:                       
>           Hash Cond: ((t3.eventname)::text = (t4.name)::text)
>  WARN 2013-04-22 13:01:20,414 (Stuffer thread) -  Plan:                       
>           ->  Seq Scan on prereqevents t3  (cost=0.00..4438.54 rows=231554 
> width=37)
>  WARN 2013-04-22 13:01:20,414 (Stuffer thread) -  Plan:                       
>           ->  Hash  (cost=11.40..11.40 rows=140 width=516)
>  WARN 2013-04-22 13:01:20,414 (Stuffer thread) -  Plan:                       
>                 ->  Seq Scan on events t4  (cost=0.00..11.40 rows=140 
> width=516)
>  WARN 2013-04-22 13:01:20,414 (Stuffer thread) -  Plan:                     
> ->  Seq Scan on jobs t1  (cost=0.00..2.03 rows=2 width=8)
>  WARN 2013-04-22 13:01:20,414 (Stuffer thread) -  Plan:                       
>     Filter: ((status = ANY ('{A,a}'::bpchar[])) AND (priority = 5::bigint))
>  WARN 2013-04-22 13:01:20,414 (Stuffer thread) -  Plan:               ->  
> Index Scan using i1362584563120 on jobqueue t2  (cost=0.00..4.30 rows=1 
> width=49)
>  WARN 2013-04-22 13:01:20,414 (Stuffer thread) -  Plan:                     
> Index Cond: ((dochash)::text = (t0.dochash)::text)
>  WARN 2013-04-22 13:01:20,414 (Stuffer thread) -  Plan:                     
> Filter: (status = ANY ('{A,F,a,f,D,d}'::bpchar[]))
>  WARN 2013-04-22 13:01:20,414 (Stuffer thread) - 
> {code}
> Here's the query:
> {code}
> EXPLAIN SELECT 
> t0.id,t0.jobid,t0.dochash,t0.docid,t0.status,t0.failtime,t0.failcount,t0.priorityset
>  FROM jobqueue t0  WHERE t0.status IN ('P','G') AND t0.checkaction='R' AND 
> t0.checktime<=1366628406182 AND
>     EXISTS(SELECT 'x' FROM jobs t1 WHERE t1.status IN ('A','a') AND 
> t1.id=t0.jobid AND t1.priority=5) AND
>     NOT EXISTS(SELECT 'x' FROM jobqueue t2 WHERE t2.dochash=t0.dochash AND 
> t2.status IN ('A','F','a','f','D','d') AND t2.jobid!=t0.jobid) AND
>     NOT EXISTS(SELECT 'x' FROM prereqevents t3,events t4 WHERE t0.id=t3.owner 
> AND t3.eventname=t4.name) ORDER BY t0.docpriority ASC LIMIT 100;
> {code}
> This query was noted in the log as taking 76 seconds to execute.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to