Re: Getting row with id=max(id)
От | Peter Eisentraut |
---|---|
Тема | Re: Getting row with id=max(id) |
Дата | |
Msg-id | Pine.LNX.4.30.0106071929140.757-100000@peter.localdomain обсуждение исходный текст |
Ответ на | Getting row with id=max(id) (Gerald Gutierrez <gml1@coldresist.com>) |
Ответы |
Re: Getting row with id=max(id)
|
Список | pgsql-sql |
Gerald Gutierrez writes: > SELECT * FROM mytable WHERE id=(SELECT MAX(id) FROM mytable); > > The subquery can take a /really/ long time on a table that is large. The query: > > SELECT * FROM mytable ORDER BY id DESC LIMIT 1; > > doesn't seem to help very much. What query is the fastest at getting this row? One of these two. ;-) The second is generally thought to be faster, at least if you use the latest version of PostgreSQL. > A related question is: is there a way to time a query in psql, like the > client of MySQL does? Not in a built-in way. -- Peter Eisentraut peter_e@gmx.net http://funkturm.homeip.net/~peter
В списке pgsql-sql по дате отправления: