Re: [PERFORM] Slow query to get last created row using CURRVAL

2010-12-04 Thread Віталій Тимчишин
2010/12/4 Mathieu De Zutter > > For each page load I first create an entry in that table, e.g.: > > INSERT INTO log_event (user_id, ip, action_id, object1_id, object2_id, > event_timestamp, comments) VALUES (1, '127.0.0.1', 96, null, null, > NOW(), 'TEST'); > > After that, I want to retrieve the

Re: [PERFORM] Slow query to get last created row using CURRVAL

2010-12-04 Thread Mathieu De Zutter
On Sat, Dec 4, 2010 at 1:35 PM, Marti Raudsepp wrote: > On Sat, Dec 4, 2010 at 13:56, Mathieu De Zutter 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

Re: [PERFORM] Slow query to get last created row using CURRVAL

2010-12-04 Thread Marti Raudsepp
On Sat, Dec 4, 2010 at 13:56, Mathieu De Zutter 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

[PERFORM] Slow query to get last created row using CURRVAL

2010-12-04 Thread Mathieu De Zutter
Hi all, I have a table that stores all the page loads in my web application: shs-dev=# \d log_event Table "public.log_event" Column | Type | Modifiers -+--+-