Salis Posted June 1, 2007 Share Posted June 1, 2007 OK, this is what I'm doing. I'm working on a website and on the main page I need to pull data from my database. What I need to pull is the main content form one table, then I need to get the 8 most recent posts from my forums, and the top 8 most downloaded files as well as may be pulling user information. Now this site is a little different from others in that it's user friendly err that users can actually modify the site to their taste. I'm starting the php coding now and I'm wondering if it's a better idea to query all at once (which I'm not sure how to do exactly) however I do know how to query every thing individually. So I don't really know. I've read articles and read that sometimes it may be better to do a 2 or 3 queries to reduce overhead, which makes since if you have a few visitors, but how would it play out on heavy traffic? Quote Link to comment https://forums.phpfreaks.com/topic/53894-solved-is-it-better-to-have-1-big-query-or-3-4-smaller-ones/ Share on other sites More sharing options...
bubblegum.anarchy Posted June 2, 2007 Share Posted June 2, 2007 Usually one large, well designed, query is better than four smaller queries.... but I do recall an instance where splitting a small portion of a large query resulted in a decreased page load time - this depends on how connected that query table is to the original source and what information is available to query against. Quote Link to comment https://forums.phpfreaks.com/topic/53894-solved-is-it-better-to-have-1-big-query-or-3-4-smaller-ones/#findComment-266596 Share on other sites More sharing options...
fenway Posted June 2, 2007 Share Posted June 2, 2007 It really does depends on a lot of things... but I agree with b.a. Quote Link to comment https://forums.phpfreaks.com/topic/53894-solved-is-it-better-to-have-1-big-query-or-3-4-smaller-ones/#findComment-266635 Share on other sites More sharing options...
obsidian Posted June 2, 2007 Share Posted June 2, 2007 It really does depends on a lot of things... but I agree with b.a. I'll third that sentiment, FWIW. Quote Link to comment https://forums.phpfreaks.com/topic/53894-solved-is-it-better-to-have-1-big-query-or-3-4-smaller-ones/#findComment-266642 Share on other sites More sharing options...
Salis Posted June 4, 2007 Author Share Posted June 4, 2007 Thanks guys. I do hope for my site to really grow so I think if I do make a few queries it may be for the bes in the long run. Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/53894-solved-is-it-better-to-have-1-big-query-or-3-4-smaller-ones/#findComment-267552 Share on other sites More sharing options...
Wildbug Posted June 5, 2007 Share Posted June 5, 2007 It sounds like the information that you're querying is very different -- main content vs. eight posts from another table, etc. You'll necessarily be writing seperate queries for these. If I'm misunderstanding and a single query does make sense, and can be written in four queries, then you should benchmark to be sure which is faster. If you do encounter heavy traffic, another option may be to keep some things stored on disk, such as your main site content, for instance. Keeping those in files on disk could avoid database overhead. Quote Link to comment https://forums.phpfreaks.com/topic/53894-solved-is-it-better-to-have-1-big-query-or-3-4-smaller-ones/#findComment-268449 Share on other sites More sharing options...
Salis Posted June 5, 2007 Author Share Posted June 5, 2007 Well this site is like nothing I've worked on before. Right now what I'm trying to do is create a custom forum. I've decided to get rid of the download section and go with a "Most Viewed" this will work as the same idea but reduce the amount of rows in my database. When you go to my site, the main index page will do a few things. 1. Read the 8-10 latest topics in my forums (which I do need help coding the forums if any one is will to donate the time) 2. Then it reads the the 8-10 most viewed files 3. If you're logged in check to see what template you have set as default and apply that. I don't have much of any thing up right now, but my site http://vx-fx.com Quote Link to comment https://forums.phpfreaks.com/topic/53894-solved-is-it-better-to-have-1-big-query-or-3-4-smaller-ones/#findComment-268590 Share on other sites More sharing options...
Salis Posted June 5, 2007 Author Share Posted June 5, 2007 Actually now that I think about it, If I only need to pull no more than 24 rows from the database, the perhaps joining the queries would work, but there is a problem that lies in that. I've read articles and tutorials on JOIN but I don't really get it............. Quote Link to comment https://forums.phpfreaks.com/topic/53894-solved-is-it-better-to-have-1-big-query-or-3-4-smaller-ones/#findComment-268601 Share on other sites More sharing options...
fenway Posted June 6, 2007 Share Posted June 6, 2007 Well, I suggest you start another topic, then. Quote Link to comment https://forums.phpfreaks.com/topic/53894-solved-is-it-better-to-have-1-big-query-or-3-4-smaller-ones/#findComment-269119 Share on other sites More sharing options...
Salis Posted June 6, 2007 Author Share Posted June 6, 2007 Yeah. But before I do I'll do a deep search. Quote Link to comment https://forums.phpfreaks.com/topic/53894-solved-is-it-better-to-have-1-big-query-or-3-4-smaller-ones/#findComment-269161 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.