Question from the Infrastructure Architecture test

Which of the following two SQL queries is faster? A: SELECT * FROM table WHERE id = 1; B: SELECT * FROM table WHERE id = 1 ORDER BY id;

Medium

SAME SUBJECT FOR MULTIPLE QUESTIONS

You have a database in heavy documents (1 document/row contains 1Mo of data). You notice that the bottleneck of your database is not the number of read/write requests but the amount of data passing through for each request (1Mo).

Your database allows you to perform atomic operations on multiple tables/collections.

Writing documents/rows is done in 1 write. Reading is partial (users only need subsets of the information in the documents/rows at the same time). You identify 3 subsets, of respective sizes 0.2Mo 0.6Mo 0.5Mo. The read / write ratio being 5, you decide to differentiate the channels used for writing from those for reading to take advantage of the fact that reads do not pass as much data.

Idea A is physical redundancy. You attach a slave database to your current database. The latter will receive the write operations, which will be replicated on the slave database. The read operations will be directed directly to the slave tables.

Idea B is to keep tables for each of the subsets (in addition to the main table). These tables are therefore persistent caches, in the database. 1 write operation therefore writes the main document/row + 1 small document/row ready to use for each of the read operations (3).

Idea C is to write custom SQL/mapReduce queries for each of the read operations in order to return only the necessary subsets for each of the reads. Your database is therefore not modified and you have three custom interfaces for each of the subsets.

IN TERMS OF READING SPEED:

Author: Kevin LefevreStatus: PublishedQuestion passed 209 times
Edit
0
Community EvaluationsNo one has reviewed this question yet, be the first!