<p>When and how should table stats gathering be performed for Oracle, version 9 and up? How would you go about gathering stats for a large database, where stats gathering would collide with "business hours".</p>

[{'answer_id': 36927, 'author': 'stevechol', 'author_id': 2981, 'author_profile': 'https://Stackoverflow.com/users/2981', 'pm_score': 2, 'selected': True, 'text': "<p>Gathering stats should be done whenever there has been large changes to the data content, for example a large number of deletes or inserts.  If the table structure has changed you should gather stats also.  It is advisable to use the 'ESTIMATE' option.</p>\n\n<p>Do this as an automated process out of business hours if possible, or if you have to do it during business hours then choose a time when there is minimum access to the tables you wish to gather stats for.</p>\n"}, {'answer_id': 109982, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>Make sure when using the estimate (sample_percent) that you gather at least 10 percent.  Below that can yield very questionable results.</p>\n'}, {'answer_id': 116207, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': "<p>Consider backing up current stats when gathering -- that way you can compare them (if you're interested) and possibly restore them if your new stats cause problems.  Keep in mind that stats are used to determine execution plans -- you may only want to gather them if you want execution plans to change.</p>\n"}, {'answer_id': 117066, 'author': 'Nick Pierpoint', 'author_id': 4003, 'author_profile': 'https://Stackoverflow.com/users/4003', 'pm_score': 3, 'selected': False, 'text': "<p>I don't agree that you should always rebuild your statistics after there have been lots of deletes or inserts. As ever, it depends. In a data warehouse situation, when re-building your materialized views you will be doing lots of deletes and inserts but the base structure of the data will not change.</p>\n\n<p>You only need to re-calculate statistics on a table if there has been a <em>significant</em> change in its content. This does <em>not</em> necessarily mean after lots of deletes or inserts, but rather when deletes, inserts, or updates materially change the content with respect to possible execution plans.</p>\n\n<p>If you are truncating tables and rebuilding (which will reset your statistics), instead of an expensive statistics calculation, you're often better off storing the statistics before truncating and restoring them once you've rebuilt the table.</p>\n\n<p>For saving the current views of statistics you use:</p>\n\n<pre><code>dbms_stats.export_table_stats\n</code></pre>\n\n<p>and to restore them afterwards you use:</p>\n\n<pre><code>dbms_stats.import_table_stats\n</code></pre>\n\n<p>(There are corresponding procedures for <code>schema</code> and <code>database</code>.)</p>\n"}]
['https://Stackoverflow.com/questions/36813', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3839/']