Jump to content

Connections&Tables


Illasera

Recommended Posts

Hey all,I have 2! 2 questions!1.)In almost every page on my website, am querying some sort of information from MySQL(IASM) databases, Meaning that every web page need to connect/close connection to MySQL Storage server,A.)I would like to know how does the connect/close connection effects my data-traffic and performance on my hosting server.B.)If asking for connection for every page per every client is to much and can cause overflow of data or some sort of bottleneck, is there a way to come around it, A more optimized way to establish connections?2.)I have ~3 (Or any other number of ) tables in MySQL IASM storage servers, Every table hosts different type of data, E.G a.)User datab.)Salesc.)Mini-blog(Newslatter)Is selecting and querying from different table can cause some sort of data-traffic/performance issue? can it cause some sort of overflow of data?If so , What`s the best way to optimize it? Put everything in one table?(Although it wont be neat anymore).Performance/Speed/Correct memory management are keys here.Thanks in advance.

Link to comment
Share on other sites

Every connection to the database takes some time and processing power from the server. That's why large websites that have a lot of traffic use large data centers with hundreds of servers to handle the load.If the data does change that often (a blog or information site) you could use caching to reduce the amount of hits to the database.I would have to see the structure of your tables and some examples of what kind of queries you want to do. Generally, if you are joining tables in a query then that will require more processing power than a query to a single table.

Link to comment
Share on other sites

Every connection to the database takes some time and processing power from the server. That's why large websites that have a lot of traffic use large data centers with hundreds of servers to handle the load.If the data does change that often (a blog or information site) you could use caching to reduce the amount of hits to the database.I would have to see the structure of your tables and some examples of what kind of queries you want to do. Generally, if you are joining tables in a query then that will require more processing power than a query to a single table.
1.)The mini-blog updates once per week so no need caching.2.)Each webpage uses different tables, so no combining needed
Link to comment
Share on other sites

1. Because the blog only updates once per week than caching would be a good thing since there is no need to hit the database every time since the content hasn't changed. You could easily cache the page for 1 hour.2. If you are querying single tables then there isn't much to worry about as long as you are not returning a large number of records.

Link to comment
Share on other sites

1. Because the blog only updates once per week than caching would be a good thing since there is no need to hit the database every time since the content hasn't changed. You could easily cache the page for 1 hour.2. If you are querying single tables then there isn't much to worry about as long as you are not returning a large number of records.
Ok, Noted, Another question : Am i allowed to create a header & footer, and write mysql_connection in the header and mysql_close in the footer? (including() both files to the context files/web pages)Will the browsers know how to handle the mysql_connection/close? Assuming the parameters are defined in different places, E.G
(header.php - File #1)<?php$connection = mysql_connection("localhost" "bla" "bla");?>

(footer.php - File #2)<?phpmysql_close($connection)?>

(Context.php - File #3)<?phpinclude("header.php");include("footer.php");?>

Thanks in advance

Link to comment
Share on other sites

Yes, that should be fine.Remember that your PHP code is run on the server, the browser will never see it. All the browser sees is what the PHP code outputs.
Thank you , Although What i am trying to ask is, Since every php file has local variables, once the file ends, does php include() function also include the local variables in other files or they cease to exist once the file terminate.
Link to comment
Share on other sites

Include is exactly like copying the code from the included file and pasting it over the include statement. It literally does the same thing, it gets the code in the other file and just starts executing it as though it were in place of the include statement. Variables are not scoped to files, each file that is included goes into the same global scope.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...