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 > large query by ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 15441 of 16172
Post > Topic >>

large query by offset and limt

by finecur <finecur@[EMAIL PROTECTED] > May 2, 2008 at 02:01 PM

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.
So I do this:

select * from huge_table where userid = 100 limit 1000 offset 0
and then send the results to user, then

select * from huge_table where userid = 100 limit 1000 offset 1000
and then send the results to user, then

select * from huge_table where userid = 100 limit 1000 offset 2000
and then send the results to user,

Continue this until there is no records available

It runs great but it is kind of slow. I think it is because even I
need only 1000 records, the query search the whole table every time.

Is there a better way to do this?

Thank you.

ff
 




 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
tan13V112 Thu Jul 24 13:11:29 CDT 2008.