On Sat, Dec 4, 2010 at 1:35 PM, Marti Raudsepp <[email protected]> wrote: > On Sat, Dec 4, 2010 at 13:56, Mathieu De Zutter <[email protected]> wrote: >> I have no idea why in some cases the index scan is not considered. >> Does anyone have an idea? > > I guess that it's because the currval() function is volatile -- its > value has to be tested for again each row. > > Try this instead: > SELECT user_id FROM log_event WHERE id = (SELECT CURRVAL('log_event_id_seq')); > > This will assure that there's only one call to currval().
OK, that makes a lot of sense. Your suggestion solves my problem. Thanks! Mathieu -- Sent via pgsql-performance mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance
