Re: Slow query - SELECTing one row from 'big' table. - Mailing list pgsql-sql

From Tom Lane
Subject Re: Slow query - SELECTing one row from 'big' table.
Date
Msg-id 22145.1131031055@sss.pgh.pa.us
Whole thread Raw
In response to Slow query - SELECTing one row from 'big' table.  (Mario Splivalo <mario.splivalo@mobart.hr>)
List pgsql-sql
Mario Splivalo <mario.splivalo@mobart.hr> writes:
>          SELECT *
>          FROM messages
>          WHERE (id = currval(''public.message_id_seq''::text))

That cannot legally be converted into an indexscan, because currval() is
a volatile function --- the planner cannot be certain that its value
won't change during the query.  (In this case we can assume it's safe
because nothing in that query would call nextval(), but the planner
isn't omniscient enough to make that conclusion.)

Fetch the currval into a local variable and use the variable in the
query.
        regards, tom lane


pgsql-sql by date:

Previous
From: Achilleus Mantzios
Date:
Subject: Re: Welcome to the pgsql-sql list!
Next
From: Don Drake
Date:
Subject: Encoding on 8.0.4