Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm writing a rest service. For each request I use about 4-8 queries.

Should I try to refactor those into a single query?

share|improve this question
    
Some options here:stackoverflow.com/questions/2336362/… – NoChance Oct 18 '15 at 20:47

It very much depends on the data.

However what you really really want to avoid is getting a number of rows from one query and then for each row firing of a second query for each row returned. In this situation a single join query will perform an order of magnitude faster than several individual queries.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.