Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How many SQL connections is too many?

Featured Replies

I'm trying to get a general rule of thumb on how many SQL connections should be used at max on each page. My website's profile page at the moment is using about 10-12 connections in order for it to display all the info it needs, I was wondering if this was too many.

 

Also, is there a way to reduce the number of connections but still retrieving the same data?

Edited by adamsmith

One connection should be all you need. You can run queries multiple times using the same connection. So if you use 10-12 for one page load, then you're using 9-11 too many!

  • Author

One connection should be all you need. You can run queries multiple times using the same connection. So if you use 10-12 for one page load, then you're using 9-11 too many!

I'm sorry, I meant queries, I'm using one connection per page but there are 10-12 queries, i guessed that each query was almost like a connection to the database each time...

It depends on what data you are pulling from the db. You're going to have to provide more information on the tables and structures

I'm sorry, I meant queries, I'm using one connection per page but there are 10-12 queries, i guessed that each query was almost like a connection to the database each time...

 

You can never really tell how many queries is too many because you can have a web page that looks like the following:

* A banner image on top from an ad manager script

* The site title pulled from a CMS table

* The home page content obtained from a CMS table

* A sidebar newsfeed obtained from querying a table containing blog posts

* A footer containing links obtained from another CMS table

 

These are 5 queries right here so if you compare that to a static HTML page that has no database interaction at all, you are looking at two very different pages right there. You can also have a 'chat' page that makes a database query every 20 seconds so there could be over a hundred database queries being made by that page (though, ideally, one shouldn't built a chat application in this manner the world is less than perfect).

 

If you aren't experiencing any kind of a performance problem or foresee a performance problem in future, you probably don't need to bother about the number of queries or the number of connections because the effort you put into it may not really pay off... though if you can do it right, you should, as it would be a great learning experience.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.