Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql General > Re: large query...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 5 Topic 15441 of 17602
Post > Topic >>

Re: large query by offset and limt

by craig@[EMAIL PROTECTED] (Craig Ringer) May 4, 2008 at 02:34 AM

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

-- 
Sent via pgsql-general mailing list (pgsql-general@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
 




 5 Posts in Topic:
large query by offset and limt
finecur <finecur@[EMAI  2008-05-02 14:01:43 
Re: large query by offset and limt
steve@[EMAIL PROTECTED]   2008-05-03 11:17:00 
Re: large query by offset and limt
craig@[EMAIL PROTECTED]   2008-05-04 02:34:38 
Re: large query by offset and limt
Ge Cong <gecong@[EMAI  2008-05-03 13:53:36 
Re: large query by offset and limt
craig@[EMAIL PROTECTED]   2008-05-04 08:56:54 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Dec 1 19:58:14 CST 2008.