Re: Fetch a single record
От
Peter Eisentraut
Тема
Re: Fetch a single record
Дата
Msg-id
200312092121.37830.peter_e@gmx.net
Ответ на
Fetch a single record (david_shadovitz@xontech.com (David Shadovitz))
Список
Дерево обсуждения
Fetch a single record david_shadovitz@xontech.com (David Shadovitz)
Re: Fetch a single record Peter Eisentraut <peter_e@gmx.net>
Re: Fetch a single record Paul Thomas <paul@tmsl.demon.co.uk>
Re: Fetch a single record greg@turnstep.com
David Shadovitz wrote: > I'm looking for the fastest way to fetch a single record from a > table. I don't care what record it is. > > Here are two techniques I've explored: > > 1. Use LIMIT > SELECT * FROM myTable LIMIT 1 > > 2. Get a valid OID and then get the record. > SELECT MIN(oid) AS anOID FROM myTable > SELECT * FROM myTable WHERE oid = anOID > > The 1st technique is slow. (I think PostgreSQL fetches all records > and then returns just one.) The 2nd is faster, but not fast enough. This is hard to believe. The first technique should be the fasted, but might suffer from a bad plan. Please make sure that you have run ANALYZE, and then post EXPLAIN ANALYZE output.
В списке pgsql-sql по дате отправления
От: jeff@dnuk.com
Дата:
От: David B
Дата: