473,397 Members | 1,961 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,397 software developers and data experts.

displaying thousands and thousands of records via PHP/HTML

I have currently devised a way to display up to 3,000 records via
PHP/HTML by using pagination techniques that stuff an entire DB query
resultset into a $_SESSION object to use within pagination.

Here's my question: How good will this work when we start dealing with
more than 3,000 records? Like 5,000? 10,000? 10,000+? The $_SESSION
object will obviously become too large to be manageable.

What do you guys advise I do to manage this in the foreseeable future?
No rush on this of course for now.

Thanx
Phil

Mar 13 '06 #1
13 4227
Don't do it. You'll kill the webserver. It's also just an incredibly
bad way of doing it.

You should be forming queries that limit the resultset and provide the
results on demand.

With MySQL you can do something like...

SELECT foo FROM bar LIMIT x,y

.... where x and y are the start record, and number of records to grab.

Mar 13 '06 #2

jonathan.beckett wrote:
Don't do it. You'll kill the webserver. It's also just an incredibly
bad way of doing it.

Why? Wouldn't hitting the database hundreds of times be even worse?
You should be forming queries that limit the resultset and provide the
results on demand.

With MySQL you can do something like...

SELECT foo FROM bar LIMIT x,y

... where x and y are the start record, and number of records to grab.


Yeah but the customer demands that they be able to do this:

1) Sort all of the existing records by multiple fields
2) Search all existing records according to a fulltext field
3) Be able to view Page 127 or 40 or 3 or whatever entirely on the fly
WHILE looking at the paginated 10 - 20 records that they are able to
see upfront.

Phil

Mar 13 '06 #3
NC
comp.lang.php wrote:
jonathan.beckett wrote:
Don't do it. You'll kill the webserver. It's also just an incredibly
bad way of doing it.


Why? Wouldn't hitting the database hundreds of times be even worse?


Not in your case; your MySQL client may end up running out of memory
due to the large size of the result set...

Cheers,
NC

Mar 13 '06 #4
In article <11**********************@z34g2000cwc.googlegroups .com>,
"comp.lang.php" <ph**************@gmail.com> wrote:
jonathan.beckett wrote:
Don't do it. You'll kill the webserver. It's also just an incredibly
bad way of doing it.


Why? Wouldn't hitting the database hundreds of times be even worse?
You should be forming queries that limit the resultset and provide the
results on demand.

With MySQL you can do something like...

SELECT foo FROM bar LIMIT x,y

... where x and y are the start record, and number of records to grab.


Yeah but the customer demands that they be able to do this:

1) Sort all of the existing records by multiple fields
2) Search all existing records according to a fulltext field
3) Be able to view Page 127 or 40 or 3 or whatever entirely on the fly
WHILE looking at the paginated 10 - 20 records that they are able to
see upfront.


All of which you handle with a db query, not by saving db query
results.

select * from db order by date desc, headline limit 127,40

Will show all and sort by date field first, descending, and headline
next, ascending. And will begin at result number 127 and show 40
results.

PIece of cake. What you mean by "WHILE looking at the paginated 10-20
records" I don't know, but opening another result in a new window, or
in a frame or in a DIV isn't very hard.
--
Sandman[.net]
Mar 13 '06 #5
NC wrote:
comp.lang.php wrote:
jonathan.beckett wrote:
> Don't do it. You'll kill the webserver. It's also just an incredibly
> bad way of doing it.
Why? Wouldn't hitting the database hundreds of times be even worse?

Not in your case; your MySQL client may end up running out of memory
due to the large size of the result set... Cheers,
NC

why would anyone need to display resultsetst that large - they are
generally worthless to look at and even less useful to find the
information you really need to see...

If the resultsets are too large you will:

Kill the server - returning all of those records
Kill the network - saturate it with unnecessary data.
Kill the DSL/Cable connection
Kill the PC - trying to download the information
Kill the Browser... Can you say - need more memory?
Depending on the number of requests for this process, 1 and 2 will most
likely bite you.

Mar 13 '06 #6

noone wrote:
NC wrote:
comp.lang.php wrote:
jonathan.beckett wrote:
> Don't do it. You'll kill the webserver. It's also just an incredibly
> bad way of doing it.

Why? Wouldn't hitting the database hundreds of times be even worse?
Not in your case; your MySQL client may end up running out of memory
due to the large size of the result set...

Cheers,
NC

why would anyone need to display resultsetst that large - they are
generally worthless to look at and even less useful to find the
information you really need to see...

If the resultsets are too large you will:

Kill the server - returning all of those records
Kill the network - saturate it with unnecessary data.
Kill the DSL/Cable connection
Kill the PC - trying to download the information
Kill the Browser... Can you say - need more memory?

As lame as it is going to sound, the customer wants to be able to view
ANY of their existing records whenever they want, including the option
to [shudders] "View ALL students".. yes, they want to be able to view
all 3,000, 4,000, zillion student at one time if they choose to do so.
*sigh*

Phil

Depending on the number of requests for this process, 1 and 2 will most
likely bite you.


Mar 13 '06 #7
comp.lang.php wrote:

noone wrote:
NC wrote:
> comp.lang.php wrote:
>> jonathan.beckett wrote:
>> > Don't do it. You'll kill the webserver. It's also just an incredibly
>> > bad way of doing it.
>>
>> Why? Wouldn't hitting the database hundreds of times be even worse?
> Not in your case; your MySQL client may end up running out of memory
> due to the large size of the result set...

> Cheers,
> NC

why would anyone need to display resultsetst that large - they are
generally worthless to look at and even less useful to find the
information you really need to see...

If the resultsets are too large you will:

Kill the server - returning all of those records
Kill the network - saturate it with unnecessary data.
Kill the DSL/Cable connection
Kill the PC - trying to download the information
Kill the Browser... Can you say - need more memory?

As lame as it is going to sound, the customer wants to be able to view
ANY of their existing records whenever they want, including the option
to [shudders] "View ALL students".. yes, they want to be able to view
all 3,000, 4,000, zillion student at one time if they choose to do so.
*sigh* Phil


Depending on the number of requests for this process, 1 and 2 will most
likely bite you.


What I have done in the past is that if they want that much data - the
browser is the wrong tool for the job -- is to send headers such that it
thinks it is a CSV file (application/excel???) and let them open it up in
Excel.

I have also dumped the data to a tmp file, opened the file and only read x
number of lines at a time... Depending on the file size - takes longer
and longer to retrieve the data - but it worked...

sometimes it can be a learning experience for the customer. There are
times when you need to "coach" them into thinking that it is a very bad
idea. Especially since there could a lot of personnal data displayed -
which is a huge security risk.

What school so I know not to send my kids there...? :)

Mar 13 '06 #8

noone wrote:
comp.lang.php wrote:

noone wrote:
NC wrote:

> comp.lang.php wrote:
>> jonathan.beckett wrote:
>> > Don't do it. You'll kill the webserver. It's also just an incredibly
>> > bad way of doing it.
>>
>> Why? Wouldn't hitting the database hundreds of times be even worse?

> Not in your case; your MySQL client may end up running out of memory
> due to the large size of the result set...

> Cheers,
> NC
why would anyone need to display resultsetst that large - they are
generally worthless to look at and even less useful to find the
information you really need to see...

If the resultsets are too large you will:

Kill the server - returning all of those records
Kill the network - saturate it with unnecessary data.
Kill the DSL/Cable connection
Kill the PC - trying to download the information
Kill the Browser... Can you say - need more memory?

As lame as it is going to sound, the customer wants to be able to view
ANY of their existing records whenever they want, including the option
to [shudders] "View ALL students".. yes, they want to be able to view
all 3,000, 4,000, zillion student at one time if they choose to do so.
*sigh*

Phil


Depending on the number of requests for this process, 1 and 2 will most
likely bite you.


What I have done in the past is that if they want that much data - the
browser is the wrong tool for the job -- is to send headers such that it
thinks it is a CSV file (application/excel???) and let them open it up in
Excel.

I have also dumped the data to a tmp file, opened the file and only read x
number of lines at a time... Depending on the file size - takes longer
and longer to retrieve the data - but it worked...

sometimes it can be a learning experience for the customer. There are
times when you need to "coach" them into thinking that it is a very bad
idea. Especially since there could a lot of personnal data displayed -
which is a huge security risk.

What school so I know not to send my kids there...? :)


A branch of the U.S. Federal Government, and sorry, a webpage is a
federally-mandated requirement in this case.

Phil

Mar 13 '06 #9
I had to make something very similar for a mailing list, ~5000 records.
Store the query information (not the data/result set) in session, this
mean the start/count for the LIMIT clause

What i would do is use get requests to specify the offset
?start=10&number=100
or just hide the start/number by doing ?page=5, and do the calculation
for offset/count in the php
?start=all to show all records

processing that much is going to be slow and may bog the browser down.
It may be better to send a csv file so they can view it in excel,
instead.

If you're dealing with large results sets, I'm willing to bet PHP will
bog down (if you're storing it all into an array or something) before
the database server begins to bog down.

Mar 13 '06 #10

Richard Levasseur wrote:
I had to make something very similar for a mailing list, ~5000 records.
Store the query information (not the data/result set) in session, this
mean the start/count for the LIMIT clause

What i would do is use get requests to specify the offset
?start=10&number=100
or just hide the start/number by doing ?page=5, and do the calculation
for offset/count in the php
?start=all to show all records

processing that much is going to be slow and may bog the browser down.
It may be better to send a csv file so they can view it in excel,
instead.

If you're dealing with large results sets, I'm willing to bet PHP will
bog down (if you're storing it all into an array or something) before
the database server begins to bog down.


Ok it took a bit of effort and guesswork but I was able to upgrade my
existing Pagination class methodology to allow for the optional
limitation of the query by adding an additional field

SELECT id, first_name, last_name, (SELECT count(id) FROM people) AS
total FROM people GROUP BY id, first_name, last_name, total ORDER BY
upper(last_name) ASC, upper(first_name) ASC LIMIT 0, 10

What I have to do is to look for the instance in the resultset for
$result[0]->pagination_total and if found, bypass the $_SESSION
handling altogether.

Thanx all!

Phil

Mar 13 '06 #11
NC
noone wrote:

why would anyone need to display resultsetst that large


I can think of a couple of reasons, such as importing it into another
program for statistical analysis...

Cheers,
NC

Mar 14 '06 #12
comp.lang.php wrote:
I have currently devised a way to display up to 3,000 records via
PHP/HTML by using pagination techniques that stuff an entire DB query
resultset into a $_SESSION object to use within pagination.


You know, that's not very efficient. PHP always write session variables
to disk, even when there are no changes. Your server will end up doing
a lot of unnecessary disk writes. Given that a write operation always
lead to mechanical actions while a read operation can be fully cached,
I say you'd be better off re-running the query on each page.

Mar 14 '06 #13
It should also be noted that queries are cached by the database server,
so subsequent queries will be faster, much much faster than
reading/writing from disk every page hit

Mar 14 '06 #14

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

Similar topics

9
by: R. Alan Monroe | last post by:
Subject says it all... what's the fastest way to get many thousands of records to the client? I'm trying to sketch out a traditional 3 tier client-server system. Multiple clients would make...
3
by: B | last post by:
I know there are several ways to speed up combo boxes and form loading. Most of the solutions leave rowsource of the combo box blank and set the rowsource to a saved query or an SQL with a where...
7
by: Susan Bricker | last post by:
Sorry..I keep hitting the wrong key and sending the post too soon... The problem: COMBOBOX not displaying all possible rows. The RecordSource (generated by SQL view of the Query Builder) is:...
2
by: VM | last post by:
When I display data to a Windows datagrid I usually fill the underlying table (in another class) and then, once it contains all the data, I attach it to the grid. But there are some processes that...
13
by: gooze | last post by:
Hello I am working on an applicaion that shows several pictures on a webpage. These pictures are saved in a MySQL DB as BLOB. I noticed, that the web server suffers in its performance by...
2
by: Mike | last post by:
I have a parent form with two subforms on it. Each subform lists certain records and then totals up one of the fieldsd. The parent form then totals up the two text boxes. The problem is that if...
13
by: hornedw | last post by:
I have been working on a ecommerce website for myself. What I needed some assistance on was when i was trying to display the categories/subcategories for the different products. I decided to use...
8
by: Greg Lyles | last post by:
Hi all, I'm trying to develop an ASP.NET 2.0 website and am running into some real problems with what I thought would be a relatively simple thing to do. In a nutshell, I'm stuck on trying to...
3
by: mikec87 | last post by:
I am very new with PHP...started doing this a few days ago to help someone and I need some help please. I have a webpage that is not displaying the records I want it to. The sql is correct, and I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.