Re: large query by offset and limt

Поиск
Список
Период
Сортировка
От Craig Ringer
Тема Re: large query by offset and limt
Дата
Msg-id 481CB03E.3050906@postnewspapers.com.au
обсуждение исходный текст
Ответ на large query by offset and limt  (finecur <finecur@yahoo.com>)
Список pgsql-general
finecur wrote:
> Hi, I am ruuning a database behind a webserver and there is a table
> which is huge. I need to pull data from this table and send to user
> through http. If I use
>
> select * from huge_table where userid = 100
>
> It will return millions of records which exhuasts my server's memory.

> Is there a better way to do this?

Consider using database cursors. Set up by beginning a transaction and
issuing the statement:

DECLARE huge_table_curs CURSOR FOR
SELECT * FROM huge_table WHERE userid = 100;

... then to get results, just execute:

FETCH 1000 FROM huge_table_curs;

--
Craig Ringer

В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: clustering without locking
Следующее
От: Craig Ringer
Дата:
Сообщение: Re: clustering without locking