Logging

   log all visits to your web site directly in a table. In such an application, speed is probably the most important goal; you don’t want the database to bethe bottleneck. The MyISAM and Archive storage engines would work very well because they have very low overhead and can insert thousands of records per second. The PBXT storage engine is also likely to be particularly suitable for logging purposes.


Things will get interesting, however, if you decide it’s time to start running reports to summarize the data you’ve logged. Depending on the queries you use, there’s a good chance that gathering data for the report will significantly slow the process of inserting records. What can you do?



You can also run queries at times of low load, but don’t rely on this strategy continuing to work as your application grows.


Another option is to use a Merge table. Rather than always logging to the same table,adjust the application to log to a table that contains the year and name or number of the month in its name, such as web_logs_2008_01 or web_logs_2008_jan. Then define a Merge table that contains the data you’d like to summarize and use it in your queries. If you need to summarize data daily or weekly, the same strategy works; you just need to create tables with more specific names, such as web_logs_2008_01_01.


While you’re busy running queries against tables that are no longer being written to, your application can log records to its current table uninterrupted.

你可能感兴趣的:(logging)