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

Volatile functions in subqueries don't prevent subqueries from being evaluated in initplans?

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: Postgres <pgsql-hackers(at)postgresql(dot)org>
Subject: Volatile functions in subqueries don't prevent subqueries from being evaluated in initplans?
Date: 2008-08-20 14:04:19
Message-ID: 87zln74wbg.fsf@oxford.xeocode.com (view raw or flat)
Thread:
Lists: pgsql-hackers
Hm, shouldn't this query notice that random() is volatile and not make the
subquery an initplan?


postgres=#  select i, (select (random()*1000)::integer  ) from x limit 5;
 i | ?column? 
---+----------
 1 |      677
 2 |      677
 3 |      677
 4 |      677
 5 |      677
(5 rows)

postgres=# explain  select i, (select (random()*1000)::integer  ) from x limit 5;
                        QUERY PLAN                         
-----------------------------------------------------------
 Limit  (cost=0.02..0.11 rows=5 width=4)
   InitPlan
     ->  Result  (cost=0.00..0.02 rows=1 width=0)
   ->  Seq Scan on x  (cost=0.00..64.80 rows=3480 width=4)
(4 rows)


-- 
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com
  Ask me about EnterpriseDB's RemoteDBA services!

Responses

pgsql-hackers by date

Next:From: Alvaro HerreraDate: 2008-08-20 14:15:36
Subject: make dist does not work in VPATH
Previous:From: Asko OjaDate: 2008-08-20 14:03:19
Subject: Re: Patch: plan invalidation vs stored procedures

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