Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

This question already has an answer here:

I'm studying the differences between NoSQL and SQL. If I understood correctly, there are two main techniques to optimize a database:

  1. Indexing rows. Say you wanted to make a query such as WHERE x = 1 AND y = 2. Indexing the columns "x" and "y" together could drop the lookup from O(n) to O(1). This is the main technique used in SQL.

  2. Constructing mapReduce relationships. Say you need to compute the sum of money from users. You could set a mapReduce(get_money,sum) on your database and it would cache that sum automatically, dropping lookup from O(n) to O(1) and update of the cache from O(n) to O(log(n)) because of the nature of mapReduce. This also makes parallelizing easier. Also, this is exclusive to non-relational databases.

Are those statements correct? What other techniques are important?

share|improve this question

marked as duplicate by Doc Brown, Jim G., Martijn Pieters, JeffO, World Engineer Mar 14 '13 at 14:59

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

you can edit you previous question if you want to make it clearer –  ratchet freak Mar 14 '13 at 11:49
@ratchetfreak they are different questions... –  Dokkat Mar 14 '13 at 11:55
add comment

1 Answer

You can denormalise a section of your database if you identify a performance issue.

This can mean bringing data from a related table into a "main" table to reduce the number of joins you need to make.

A very basic example could be a running count of all Orders made could be added to a Customer table. This makes the insert of a new order slightly more expensive as you have to increment the count in the customer table as well.

share|improve this answer
add comment

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