techcone Posted October 4, 2009 Share Posted October 4, 2009 Hello guys, may be my question is simple to you but for me its something I need to know I have a big script. The main purpose of script is to scrap data and store in mysql. Basically it can be structured like this : # Database Connect # Query # Scrap # Query # Scrap # Query # Disconnect What I want to know is what is best performance wise ? Opening a new connection for each query and closing after its completion ? Or open the connection once and let the script complete and then close it finally. Since scraping part will take considerable time may be 1-2 minutes. Please reply that Quote Link to comment https://forums.phpfreaks.com/topic/176440-question-related-to-database-performance/ Share on other sites More sharing options...
cags Posted October 4, 2009 Share Posted October 4, 2009 Opening the connection, then closing it when your done. I believe. Quote Link to comment https://forums.phpfreaks.com/topic/176440-question-related-to-database-performance/#findComment-930052 Share on other sites More sharing options...
pastcow Posted October 4, 2009 Share Posted October 4, 2009 I'd have to agree with cags - open, run your queries, then close. Is there no way to do Query Query Query Scrap Scrap Scrap ? Quote Link to comment https://forums.phpfreaks.com/topic/176440-question-related-to-database-performance/#findComment-930055 Share on other sites More sharing options...
techcone Posted October 4, 2009 Author Share Posted October 4, 2009 I'd have to agree with cags - open, run your queries, then close. Is there no way to do Query Query Query Scrap Scrap Scrap ? Thats the real problem the steps cant be serialize as you stated otherwise I would have done that Oke I would open connection only when needed Thanks Quote Link to comment https://forums.phpfreaks.com/topic/176440-question-related-to-database-performance/#findComment-930057 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.