DB query VS Cookies VS ??

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
rxsid
Forum Commoner
Posts: 82
Joined: Thu Aug 29, 2002 12:04 am

DB query VS Cookies VS ??

Post by rxsid »

Hi all,

I've got a web page that already makes a MySQL connection to get data for display in the middle of the page. There are 25 rows of data that are extracted and displayed.

I want to be able to have a smaller section to one side of the page, display other information...hyperlinks (perhaps up to 10 max). I'm thinking about storing these links in another table under the respective user that's logged in (therefore making these links personalized, not site standard for everyone).

My concern is that by adding a whole new db query (I realize that I can utilize the same mysql_connection, since the tables would be in the same db) to a different table, this would be a slower solution than that of other ways...such as storing the personalized links in a cookie after doing a one time only query.

Would it be better to get the link data from the db each time the page is loaded (or other pages that would display them as well), or query the db 1x then read the cookie's each time the links need to be displayed. Or is there an even better solution? What about sessions or caching (I know next to nothing about both of those)?

Thanks in advance!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

sql servers are designed to be quite fast and handle very large databases and complex queries with ease. Saying that, having 2 simple queries in a given page is trivial for it.
rxsid
Forum Commoner
Posts: 82
Joined: Thu Aug 29, 2002 12:04 am

Post by rxsid »

thanks feyd!

that's the kind of info/reassurance I was hoping to find regarding the db side of the question.
fastfingertips
Forum Contributor
Posts: 242
Joined: Sun Dec 28, 2003 1:40 am
Contact:

Post by fastfingertips »

Offcourse from the server list you should exclude Sybase and Firebird because they are not accompling to:
sql servers are designed to be quite fast and handle very large databases and complex queries with ease
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

feyd wrote:sql servers are designed to be quite fast and handle very large databases and complex queries with ease. Saying that, having 2 simple queries in a given page is trivial for it.
i have 10+ plus queries on many of my web-sites, including insert, delete, update and select statements

i have noticed no real slowdown whatsoever and my pages load up as fast in my eyes as a standard HTML page even though its very PHP heavy.

i think it very much depends on the way you organise your queries.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

It can depend on organization... but I've seen queries that are 6 pages of code, that execute extremely fast. No stored procedures (outside the built-in functions).. So it's pretty safe to assume that 2 queries of almost any size and form will run pretty damn fast.
Post Reply