Re: Index optimization ?
От | Tom Lane |
---|---|
Тема | Re: Index optimization ? |
Дата | |
Msg-id | 10434.1105813669@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Index optimization ? (Bo Lorentsen <bl@netgroup.dk>) |
Ответы |
Re: Index optimization ?
Re: Index optimization ? |
Список | pgsql-general |
Bo Lorentsen <bl@netgroup.dk> writes: > select * from sale where id = currval( 'sale_id_seq' ); This is not legally optimizable into an indexscan, because currval() is a volatile function. (It's easy to construct cases where its value actually does change from row to row --- just use a nextval() as well.) You can fake it out in a couple of ways --- the recommended method is to wrap currval in a user-defined function that is misleadingly marked stable. I think it still works to just put the call in a sub-select: select * from sale where id = (select currval( 'sale_id_seq' )); but I take no responsibility if future improvements in the planner break that trick. regards, tom lane
В списке pgsql-general по дате отправления: