HGeneAnthony Posted February 19, 2008 Share Posted February 19, 2008 I have a list of items to return. The list will be accessible through my object (each field with a function call) so I need to store results before I can display them. I was wondering is it better on performance to store the results into an object array so I only need to call the database once or should I only store 1 result at a time and make multiple calls to the database? Right now the results returned could be between 10 to 100 at a time with 5 or so fields a record. I would think doing bulk operations would be best but with memory usage and multiple connections I don't know. Suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/91981-is-it-better-to-get-results-all-at-once-or-make-multiple-calls/ Share on other sites More sharing options...
fenway Posted February 19, 2008 Share Posted February 19, 2008 If you're necessarily going to be iterating through all of them anyway, then a single db call is often more efficient. Quote Link to comment https://forums.phpfreaks.com/topic/91981-is-it-better-to-get-results-all-at-once-or-make-multiple-calls/#findComment-471088 Share on other sites More sharing options...
HGeneAnthony Posted February 19, 2008 Author Share Posted February 19, 2008 Thanx for the quick reply. I kind of thought so myself. My only concern is with having multiple users connecting to my server and available memory. Quote Link to comment https://forums.phpfreaks.com/topic/91981-is-it-better-to-get-results-all-at-once-or-make-multiple-calls/#findComment-471136 Share on other sites More sharing options...
fenway Posted February 19, 2008 Share Posted February 19, 2008 My only concern is with having multiple users connecting to my server. Be careful with this... if it's for a web app, you generally can use a single mysql user. Quote Link to comment https://forums.phpfreaks.com/topic/91981-is-it-better-to-get-results-all-at-once-or-make-multiple-calls/#findComment-471144 Share on other sites More sharing options...
HGeneAnthony Posted February 19, 2008 Author Share Posted February 19, 2008 Sorry I wrote that wrong. The people aren't connecting to my db. I plan to use a localhost user for all connections to the database but with users surfing my site at the same time I might have quite a bit of objects loaded into memory at a time if I'm saving bulk results. Granted I plan to release the objects after I use them so it might not be bad. But short term it will eat up more memory. I don't know though. I've done desktops more than websites and with a desktop I wouldn't be concerned but with a website I don't know. Quote Link to comment https://forums.phpfreaks.com/topic/91981-is-it-better-to-get-results-all-at-once-or-make-multiple-calls/#findComment-471169 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.