Llegué al cuello de botella del rendimiento de la base de datos, ¿dónde ahora?

Tengo algunas consultas que están tardando demasiado (300 ms) ahora que la base de datos ha crecido a unos pocos millones de registros. Afortunadamente para mí, las consultas no necesitan analizar la mayoría de estos datos, ya que los últimos 100,000 registros serán suficientes, por lo que mi plan es mantener una tabla separada con los 100,000 registros más recientes y ejecutar las consultas en este sentido. Si alguien tiene alguna sugerencia para una mejor manera de hacerlo, sería genial. Mi verdadera pregunta es cuáles son las opciones si las consultas debían ejecutarse contra los datos históricos, ¿cuál es el siguiente paso? Cosas que he pensado:

Actualizar hardwareUtilice una base de datos en memoriaCachee los objetos manualmente en su propia estructura de datos

¿Son correctas estas cosas y hay otras opciones? ¿Algunos proveedores de bases de datos tienen más funcionalidad que otros para hacer frente a estos problemas, p. especificando una tabla / índice particular para estar completamente en memoria?

Lo siento, debería haber mencionado esto, estoy usando mysql.

Olvidé mencionar la indexación en lo anterior. La indexación ha sido mi única fuente de mejora hasta ahora para ser bastante honesto. Para identificar cuellos de botella, he estado usando maatkit para las consultas que muestran si se están utilizando o no índices.

Entiendo que ahora me estoy alejando de lo que estaba destinada la pregunta, así que tal vez debería hacer otra. Mi problema es queEXPLAIN dice que la consulta demora 10 ms en lugar de 300 ms de lo que informa jprofiler. Si alguien tiene alguna sugerencia, realmente lo agradecería. La consulta es:

select bv.* 
from BerthVisit bv 
inner join BerthVisitChainLinks on bv.berthVisitID = BerthVisitChainLinks.berthVisitID 
inner join BerthVisitChain on BerthVisitChainLinks.berthVisitChainID = BerthVisitChain.berthVisitChainID 
inner join BerthJourneyChains on BerthVisitChain.berthVisitChainID = BerthJourneyChains.berthVisitChainID 
inner join BerthJourney on BerthJourneyChains.berthJourneyID = BerthJourney.berthJourneyID 
inner join TDObjectBerthJourneyMap on BerthJourney.berthJourneyID = TDObjectBerthJourneyMap.berthJourneyID 
inner join TDObject on TDObjectBerthJourneyMap.tdObjectID = TDObject.tdObjectID 
where 
BerthJourney.journeyType='A' and 
bv.berthID=251860 and 
TDObject.headcode='2L32' and 
bv.depTime is null and 
bv.arrTime > '2011-07-28 16:00:00'

y la salida deEXPLAIN es

+----+-------------+-------------------------+-------------+---------------------------------------------+-------------------------+---------+------------------------------------------------+------+-------------------------------------------------------+
| id | select_type | table                   | type        | possible_keys                               | key                     | key_len | ref                                            | rows | Extra                                                 |
+----+-------------+-------------------------+-------------+---------------------------------------------+-------------------------+---------+------------------------------------------------+------+-------------------------------------------------------+
|  1 | SIMPLE      | bv                      | index_merge | PRIMARY,idx_berthID,idx_arrTime,idx_depTime | idx_berthID,idx_depTime | 9,9     | NULL                                           |  117 | Using intersect(idx_berthID,idx_depTime); Using where | 
|  1 | SIMPLE      | BerthVisitChainLinks    | ref         | idx_berthVisitChainID,idx_berthVisitID      | idx_berthVisitID        | 8       | Network.bv.berthVisitID                        |    1 | Using where                                           | 
|  1 | SIMPLE      | BerthVisitChain         | eq_ref      | PRIMARY                                     | PRIMARY                 | 8       | Network.BerthVisitChainLinks.berthVisitChainID |    1 | Using where; Using index                              | 
|  1 | SIMPLE      | BerthJourneyChains      | ref         | idx_berthJourneyID,idx_berthVisitChainID    | idx_berthVisitChainID   | 8       | Network.BerthVisitChain.berthVisitChainID      |    1 | Using where                                           | 
|  1 | SIMPLE      | BerthJourney            | eq_ref      | PRIMARY,idx_journeyType                     | PRIMARY                 | 8       | Network.BerthJourneyChains.berthJourneyID      |    1 | Using where                                           | 
|  1 | SIMPLE      | TDObjectBerthJourneyMap | ref         | idx_tdObjectID,idx_berthJourneyID           | idx_berthJourneyID      | 8       | Network.BerthJourney.berthJourneyID            |    1 | Using where                                           | 
|  1 | SIMPLE      | TDObject                | eq_ref      | PRIMARY,idx_headcode                        | PRIMARY                 | 8       | Network.TDObjectBerthJourneyMap.tdObjectID     |    1 | Using where                                           | 
+----+-------------+-------------------------+-------------+---------------------------------------------+-------------------------+---------+------------------------------------------------+------+---------------------------------------

7 rows in set (0.01 sec)

Respuestas a la pregunta(7)

Su respuesta a la pregunta