473,386 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Fetching results across page loads

I would like to find a way to execute a query against an MS SQL server
and return a small number of rows each page load. However, I cannot
read all the results in during the first page load due to size
contraints.

Here are the details. A user submits a request. I construct a SQL query
and execute on the MS SQL server. The query results in a million rows.
The initial page load shows the first 100 rows. Each successive page
load shows the next 100 rows. Because our web server has limited disk
space, I do not want to return the entire result set now, but only 100
rows at a time. Also, for performance reasons, I do not want to rerun
the query each page load.

So, I need a "persistent result" set that can be fetched from across
page loads. I have tried to store the result set in a session variable
using serialize and unserialize, but to no avail. It seems that across
page loads the result set loses its way, even with a persistent
database connection.

Is this kind of peristent result set possible?

Thanks.

Jul 17 '05 #1
6 1476
I noticed that Message-ID:
<11*********************@f14g2000cwb.googlegroups. com> from
go****@macrotex.net contained the following:
Here are the details. A user submits a request. I construct a SQL query
and execute on the MS SQL server. The query results in a million rows.
The initial page load shows the first 100 rows. Each successive page
load shows the next 100 rows. Because our web server has limited disk
space, I do not want to return the entire result set now, but only 100
rows at a time. Also, for performance reasons, I do not want to rerun
the query each page load.


Why not? That's what a dbms is for.

Use LIMIT

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2
"Geoff Berrow" <bl******@ckdog.co.uk> wrote in message
news:10********************************@4ax.com...
I noticed that Message-ID:
<11*********************@f14g2000cwb.googlegroups. com> from
go****@macrotex.net contained the following:
Here are the details. A user submits a request. I construct a SQL query
and execute on the MS SQL server. The query results in a million rows.
The initial page load shows the first 100 rows. Each successive page
load shows the next 100 rows. Because our web server has limited disk
space, I do not want to return the entire result set now, but only 100
rows at a time. Also, for performance reasons, I do not want to rerun
the query each page load.


Why not? That's what a dbms is for.

Use LIMIT


AFAIK, MS SQL doesn't support the "LIMIT rowcount, offset" construct. The
recommended method, I think, is to place the recordset into a temporary
table with an identity column and retrieve the subset from there. I usually
use mssql_data_seek(), although I think the function moves forward by
pulling all the prior rows through the pipe.
Jul 17 '05 #3
I noticed that Message-ID: <U7********************@comcast.com> from
Chung Leong contained the following:
Use LIMIT


AFAIK, MS SQL doesn't support the "LIMIT rowcount, offset" construct.


Must get some reading glasses. I read that as MySql.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #4
Geoff Berrow wrote:
I noticed that Message-ID: <U7********************@comcast.com> from
Chung Leong contained the following:
Use LIMIT


AFAIK, MS SQL doesn't support the "LIMIT rowcount, offset" construct.


Must get some reading glasses. I read that as MySql.


MS SQL server does support a ROWCOUNT directive which combined with sorting
and remembering state can be used to simulate the behaviour.

C.
Jul 17 '05 #5
"Colin McKinnon" <co**************@andthis.mms3.com> wrote in message
news:d3*******************@news.demon.co.uk...
MS SQL server does support a ROWCOUNT directive which combined with sorting and remembering state can be used to simulate the behaviour.


That sub-query technique is a pain to implement though, since you have to
invert the order by clause. I've found that is acceptable performance-wise
to retrieve the primary key in one query and use them in the where clause in
a second query. Skipping through a few thousands integers isn't as bad as
skipping through thousands of rows with actual data.
Jul 17 '05 #6
Chung Leong wrote:
MS SQL server does support a ROWCOUNT directive which combined with
sorting and remembering state can be used to simulate the behaviour.


That sub-query technique is a pain to implement though, since you have to
invert the order by clause. I've found that is acceptable performance-wise
to retrieve the primary key in one query and use them in the where clause in
a second query. Skipping through a few thousands integers isn't as bad as
skipping through thousands of rows with actual data.


Can you give a brief example of how you would implement this?

Be well,
Steve
Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: nicolas_riesch | last post by:
I am writing asp pages in python, running on IIS 5 on Windows. I notice that variables outside functions keep their value across queries. I don't know if it is normal. Here is a little script...
1
by: Chris | last post by:
I'm sure there's some fancy Ajax way to do this, but I'm looking for something simple. Is it possible to fetch a page from within a javascript function? Basically what I want to do is allow the...
15
by: Kevin Hanken | last post by:
Hi, Pretty much a newbie to aspnet and xp -- I am using XP Pro, Service Pack 2. I installed IIS, set up a virtual directory, created an aspx file and pasted in a little code from the w3schools...
1
by: MD | last post by:
When displaying the metadata for our system, takes about 5 seconds to display 10 results to the browser. The whole process works like this. 1. Call the servlet from the javascript with Dom var...
22
by: Sandman | last post by:
So, I have this content management system I've developed myself. The system has a solid community part where members can register and then participate in forums, write weblogs and a ton of other...
0
by: satishr23 | last post by:
Hi, I am trying to parse the contents of a PHP page from the web which requires me to authenticate. I guess the way to do this is to make my program login to the login page,grab the cookie and...
4
by: PI | last post by:
Hi guys, I'm struggling with this much longer than I think I need to, I guess you could help me here: How do I make the results of a search display on the same page as the search, sort of beneath...
3
by: | last post by:
If this is simple, forgive my ignorance, but I'm coming from the CompactFramework where we don't use AppDomains. I did a fair bit of archive searching and couldn't find an answer and I got no...
2
by: SunshineInTheRain | last post by:
I'm trying to modify a long long code within a button click by make the insert/update/delete/select using the same transaction. Purpose is to make sure every operation can be rollback instead of some...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.