Re: Invalid optimization of VOLATILE function in WHERE clause? - Mailing list pgsql-hackers

From Kevin Grittner
Subject Re: Invalid optimization of VOLATILE function in WHERE clause?
Date
Msg-id 5059E51A020000250004A529@gw.wicourts.gov
Whole thread Raw
In response to Re: Invalid optimization of VOLATILE function in WHERE clause?  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
List pgsql-hackers
"Kevin Grittner" <Kevin.Grittner@wicourts.gov> wrote:
> There is a workaround, if you don't mind ugly:
Or, better:
WITH source AS (   SELECT i, random() AS r FROM generate_series(1,10) AS i
)
SELECT   i
FROM   source, (       SELECT           count(*) AS _n       FROM source   ) AS _stats
WHERE   r < 5::DOUBLE PRECISION/_n;
-Kevin



pgsql-hackers by date:

Previous
From: "Kevin Grittner"
Date:
Subject: Re: Invalid optimization of VOLATILE function in WHERE clause?
Next
From: "David Johnston"
Date:
Subject: Re: Invalid optimization of VOLATILE function in WHERE clause?