Skip site navigation (1) Skip section navigation (2)

Strange cost computation?

From: ives(dot)landrieu(at)ua(dot)ac(dot)be (Ives Landrieu)
To: pgsql-hackers(at)postgresql(dot)org
Subject: Strange cost computation?
Date: 2002-10-29 10:11:14
Message-ID: 17142e08.0210290211.60f6ab1e@posting.google.com (view raw or flat)
Thread:
Lists: pgsql-hackers
Hi,

Can anybody explain the following results when using EXPLAIN, 
one time with enable_seqscan=on and one time with enable_seqscan=off.
What I don't understand is that the nodes created are the same 
(index scan, seq scan), but the costs differ.  

set enable_seqscan=on;
explain (SELECT alias96.ID FROM JOB AS alias96 WHERE  NOT EXISTS
((SELECT alias97.DEPENDENT_ID FROM JOB_MISSING_DEPENDENCIES AS alias97
WHERE alias97.DEPENDENT_ID = alias96.ID)) AND  NOT EXISTS ((SELECT
alias98.JOB_ID FROM ACTIVE_JOBS AS alias98 WHERE alias98.JOB_ID =
alias96.ID)) AND ((alias96.STATUS IN (-4, -1))) FOR UPDATE OF alias96
OFFSET 10 LIMIT 10);
NOTICE:  QUERY PLAN:

Limit  (cost=458.18..916.35 rows=10 width=10)
  ->  Seq Scan on job alias96  (cost=0.00..2185013.05 rows=47689
width=10)
        SubPlan
          ->  Index Scan using job_mis6970_dependent_id_idx on
job_missing_dependencies alias97  (cost=0.00..893.88 rows=288 width=4)
          ->  Index Scan using active_jobs_job_id_key on active_jobs
alias98  (cost=0.00..4.48 rows=1 width=4)

set enable_seqscan=off;
explain (SELECT alias96.ID FROM JOB AS alias96 WHERE  NOT EXISTS
((SELECT alias97.DEPENDENT_ID FROM JOB_MISSING_DEPENDENCIES AS alias97
WHERE alias97.DEPENDENT_ID = alias96.ID)) AND  NOT EXISTS ((SELECT
alias98.JOB_ID FROM ACTIVE_JOBS AS alias98 WHERE alias98.JOB_ID =
alias96.ID)) AND ((alias96.STATUS IN (-4, -1))) FOR UPDATE OF alias96
OFFSET 10 LIMIT 10);
NOTICE:  QUERY PLAN:

Limit  (cost=100000458.18..100000916.35 rows=10 width=10)
  ->  Seq Scan on job alias96  (cost=100000000.00..102185013.05
rows=47689 width=10)
        SubPlan
          ->  Index Scan using job_mis6970_dependent_id_idx on
job_missing_dependencies alias97  (cost=0.00..893.88 rows=288 width=4)
          ->  Index Scan using active_jobs_job_id_key on active_jobs
alias98  (cost=0.00..4.48 rows=1 width=4)


Ives

Responses

pgsql-hackers by date

Next:From: Mike MascariDate: 2002-10-29 10:11:29
Subject: Re: idle connection timeout ...
Previous:From: Vladimir ChukharevDate: 2002-10-29 08:46:02
Subject: Is regress/report.php in use?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group