Home > Mobile >  Few, complex OR many, simple MySQL queries?
Few, complex OR many, simple MySQL queries?

Time:03-23

Im working on a onlineshop with php.

I work with the mvc model and I divide each small part of my application in: model view controller and service ( service is there for the query ).

So for example I would have a Item cart which is divided in discription and price...

For each of them I would have a seperate query, for example the discription: 'SELECT discription OF ... WHERE ...'

So my questin is:

Is there any downside ( like a worse performance ) if I use many simple MySQL queries instead of one complex query?

CodePudding user response:

Typically it is favorable to minimize the number of queries your application needs to execute. The reason for this is that each separate query requires a round trip to and from the database, which takes time and resources.

You did not include any actual queries, but most likely you would want to lean towards using the single complex query versus achieving the same with several queries.

  • Related