From: | lynch(at)lscorp(dot)com (Richard Lynch) |
---|---|
To: | Glenn Sullivan <glenn(dot)sullivan(at)nmr(dot)varian(dot)com> |
Cc: | pgsql-sql(at)hub(dot)org |
Subject: | Re: [SQL] Cursors |
Date: | 1998-09-23 20:09:15 |
Message-ID: | v02140b6cb22eb61f601e@[207.152.64.133] |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
>I am new to Postgre (and databases), and just figuring how to
>use it. I see numerous references to cursors, but I do not
>understand what they are for. Could someone point me to someplace
>to read, or give me one paragraph to enlighten me.
Suppose you have a *HUGE* database. Like Publisher's Clearinghouse you may
already have won a million dollars huge. If you were going to look at it
on the web, you really, REALLY, *REALLY* don't want to do a query like:
"select * from losers order by lastname, firstname"
It's pretty much guaranteed to choke the machine, eh? "Imminent Death of
the Internet, Film at 11."
So, you use a cursor. A cursor allows you to select a specific range
within a large set of records, but also have order by and group by behave
properly.
By creating a cursor and using that cursor in a query, the result set can
be calculated by the backend, but only a tiny fraction of that set will be
transmitted to the the browser at one time.
The backend *MIGHT* even be really smart and not have to do the *WHOLE*
sort, before allowing you to get the first N records, but I dunno about
that for sure.
The details on how to use cursors in PostgreSQL are in the archives, so I
won't repeat them here.
Disclaimer: Main because I dunno how to use them. I've never had a db
that large. :-)
--
--
-- "TANSTAAFL" Rich lynch(at)lscorp(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | James Olin Oden | 1998-09-23 21:49:47 | Re: [SQL] '' != NULL in PostGres??? |
Previous Message | Colin Dick | 1998-09-23 18:57:35 | Re: [SQL] '' != NULL in PostGres??? |