Does database influence page load?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
amirbwb
Forum Commoner
Posts: 89
Joined: Sat Oct 30, 2010 6:10 pm

Does database influence page load?

Post by amirbwb »

Hello,

I want to know if I am doing a list of students, which are executed from database (mysql),

does the number of data influence in the speed of the page load?

if yes:
What to do ?

And for how much data should I start to think for a solution ?

Thank you
maxx99
Forum Contributor
Posts: 142
Joined: Mon Nov 21, 2011 3:40 am

Re: Does database influence page load?

Post by maxx99 »

Yep, number of records has an impact on page load time.... but...
If its just a simple SELECT query you don't need to worry. MySQL can easily handle millions of records :)
On some point you may have to paginate the list to reduce data send between web server and user on every request.
Here's an example
http://www.sitepoint.com/perfect-php-pagination/
User avatar
amirbwb
Forum Commoner
Posts: 89
Joined: Sat Oct 30, 2010 6:10 pm

Re: Does database influence page load?

Post by amirbwb »

Thank you maxxx99, I have done a pagination, but even if I use the pagination i will include in my code to: select * from TABLE, which will get all data to count them ;) than I will use the select * from TABLE LIMIT $a,$b or whatever ...
And Yes am using mysql, and am talking about not more than 50 000 data in the students list (the table executed using pagination, but calling all student to count them all is required to make the math logic for the pagination)

tic toc tic toc

Hope I explained correctly =) THANK YOU AGAIN ^^
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Does database influence page load?

Post by Celauran »

You really shouldn't use SELECT *, well, ever. Certainly not for counting the number of records.
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Does database influence page load?

Post by McInfo »

amirbwb wrote:[...] i will include in my code to: select * from TABLE, which will get all data to count them [...]

Code: Select all

SELECT COUNT(*) AS `num_rows` FROM `my_table`
maxx99
Forum Contributor
Posts: 142
Joined: Mon Nov 21, 2011 3:40 am

Re: Does database influence page load?

Post by maxx99 »

Exec another query as McInfo proposed, this will count all of the records for you on db side :) no need to fetch whole db
User avatar
amirbwb
Forum Commoner
Posts: 89
Joined: Sat Oct 30, 2010 6:10 pm

Re: Does database influence page load?

Post by amirbwb »

mm thank you both ...
Post Reply