Prev | Current Page 42 | Next

David Berube

"Practical Reporting with Ruby and Rails"


Databases typically have numerous built-in features for speeding up data access.
Indexes, for example, are subsets of your table data, which are automatically maintained
by your database and can make searching much faster. You can think of indexes like the
table of contents in a book. It??™s much faster to find something by using the table of contents
than it is to read every page of the book looking for the desired information.
Additionally, the database??™s query planner uses speed-enhancing techniques automatically.
This query planner has access to statistical information on the various tables and
columns that your query uses, and it will formulate a query plan based on that information.
In other words, it estimates how long each method of retrieving the data you
requested will take, and it uses the quickest method. Because of the capabilities of the
database, it??™s typically best to use the techniques described in this chapter, as they are
considerably faster than doing your statistics in your Ruby code.


Pages:
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54