postgresql: Fast way to update the latest inserted row
Posted
by
Anonymous
on Stack Overflow
See other posts from Stack Overflow
or by Anonymous
Published on 2013-11-11T09:49:43Z
Indexed on
2013/11/11
9:53 UTC
Read the original article
Hit count: 295
sql
|postgresql
What is the best way to modify the latest added row without using a temporary table. E.g. the table structure is
id | text | date
My current approach would be an insert with the postgresql specific command "returning id" so that I can update the table afterwards with
update myTable set date='2013-11-11' where id = lastRow
However I have the feeling that postgresql is not simply using the last row but is iterating through millions of entries until "id = lastRow" is found. How can i directly access the last added row?
© Stack Overflow or respective owner