MySQL queries

  • Started
  • Last post
  • 2 Responses
  • welded

    Hey, I've got a pretty damn vague and subjective question for y'all. What would be considered a safe amount of SQL queries to run on a single page view. 1? 5? 10? Personally, I don't tax my DB much at all and I'm also a shitty coder, but it just doesn't seem right that I'd have to grab potentially completely unrelated info in just one complex query. Or am I just a really, really shitty coder?

  • enobrev0

    it all depends on how much each query is taking and how unrelated they are. The 'right' way has less to do with how many queries and more to do with how quick all the queries can be iplemented.

    Sometimes 6 joins will be quicker than 3 queries, and other times it's far slower.

    The best thing to do is time your queries. Maybe even build a query profiler into your database functions and watch them over time. something that lists the page called form, the query time and the total script time.

  • welded0

    That's a great idea. I've only recently moved away from cramming everything into one table so I need to develop more elegant coding practices. Thanks for the info, I appreciate it.