Re: LIMIT: does it cause the query to find all matching sets
| От | Bruce Momjian |
|---|---|
| Тема | Re: LIMIT: does it cause the query to find all matching sets |
| Дата | |
| Msg-id | 200209301508.g8UF82615027@candle.pha.pa.us обсуждение исходный текст |
| Ответ на | LIMIT: does it cause the query to find all matching sets first? (Jean-Christian Imbeault <jc@mega-bucks.co.jp>) |
| Список | pgsql-general |
Jean-Christian Imbeault wrote: > Does using LIMIT cause query execution to stop as soon as the LIMIT > number of matches have been found, or are *all* the matching rows found > first and then the first LIMIT number are returned? > > Of course this would be for a query without and ORDER BY clause. A query without ORDER BY is possible, and it will stop after it hits the limit. Of course, without ORDER BY there is no way to know which rows were returned. Second, if you do use ORDER BY, LIMIT can sometimes use an index and not have to execute the entire query, so yes, that optimization is in there. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
В списке pgsql-general по дате отправления: