• Post Reply Bookmark Topic Watch Topic
  • New Topic

number of queries per page

 
Daniil Sosonkin
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm just wondering what is considered to be normal or sane number of queries per page visit. Or does anyone know of any benchmarkings done in that area?
thanx
D.

PS: my database is mySQL
 
Billybob Marshall
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you consider a "query" and "page visit"? I'm guessing you're talking about the number of rows to show on a page from a dabase query which can return many rows. The answer is arbitrary - it depends how much data is being sent back to the client per row, and how inconvenient it is for the client to have to keep hitting "next page".
 
Daniil Sosonkin
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, I mean the number of actual SQL queries to have per page. Its independent of use hits or unique visits. At some point a JSP page is being executed and I'm just wondering what is (if any) the sane number of average SQL queries to have. Maybe its 7 or 100; I'v read people had 160 or so but on PHP. Just wondering what others have. At this point I'm afraid to stick more than 2 queries; maybe I'm overparanoid.
 
Ben Dover
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can you explain what you mean by query, and the context (and reason) in which you will want to use many of them in one page request?
 
Daniil Sosonkin
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SQL Query:
SELECT * FROM users WHERE uID = 563
or
SELECT table1.*, table2.* FROM table1 INNER JOIN table2 ON field1 = field2 INNER JOIN table3 ON somefield = 'y' WHERE uID = 563
or
SELECT * FROM pix WHERE uID = 563 ORDER BY date1 DESC, date2 ASC LIMIT 50, 100
just simple SQL queries.
 
Ben Dover
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, thats fine, but what I am trying to find out from you is what are you trying to achieve? Are you actually caling each and every query, opening and closing connections to the database for each one, what do you want to do with the information you are querying? in theory your JSP page can process as many database calls as it likes (limited by performance), but I dont get WHAT you are doing and WHY you are trying to do it.
 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The number of queries isn't really relavant. The performance of them is though. Better to define an expected performance for your page and not go over that. Obviously if the page takes 30 seconds most users will be long gone before the page renders.
 
Daniil Sosonkin
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see your point; guess didn't think it through. Nonetheless, I'm still curious how many queries do people usually do. Any kinds of SQL queries.
 
Billybob Marshall
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Daniil Sosonkin:
I see your point; guess didn't think it through. Nonetheless, I'm still curious how many queries do people usually do. Any kinds of SQL queries.

It totally depends on the app's and data's needs and design. There isn't a "this is how many queries for a normal app to do" number. The better the design, the likelyhood of the less queries that have to be done. Just strive for good design.
 
Ben Dover
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Daniil Sosonkin:
I see your point; guess didn't think it through. Nonetheless, I'm still curious how many queries do people usually do. Any kinds of SQL queries.

Well, to be blunt, any "serious" querying is not best done in JSP's but in a business layer. Separating your application using an MVC approach is more flexible, and if you are attempting high volumes of data retrieval, you have the option of caching the value objects to improve performance. The view is then created dependig on what the user wants to see.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!