• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  • You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
  • You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  • If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Previously on "Calling all SQL experts - To shrink or not to shrink?"

Collapse

  • BigRed
    replied
    I'd never shrink unless I had a pressing need for the space or knew that it would never ever grow that big again. Each time it grows there is the potential for physical fragmentation. Backups don't copy empty extents. To prove this look at your backup stats before and after the purge. The job will report xxx pages backed up in xxx seconds. If you are having performance issues you would benefit from getting a performance tuning expert in as it sounds like you are doing the general basic stuff.

    Leave a comment:


  • suityou01
    replied
    Largely databases are split into two separate areas, OLAP (Reporting) and OLTP (Transational day to day stuff).

    What tends to happen on the more organically grown systems is they start out as a few tables for transactional stuff and then as the database grows it gets hammered with the BI stick by well meaning department heads wanting meaningful reports to help manage/grow the business.

    Quick wins for database performance can be to start a warehouse project, shovel (ETL) the data in to the warehouse and run the reports from there. The sell is that the warehouse gives time slices (snapshots) of the business so can provide richer reports. The management would struggle to justify the cost as warehouses are huge and consume many acres of disk space rapidly.

    Or just stage the data for the reports elsewhere, run a nightly hose down and fresh ETL, so no time slices but freshly staged DB. You could sell this as a PreProd environment or DR system in the making.

    The important point is you get reporting load off your DB.

    Then you can run a profiler trace to identify slowly performing queries and get your DBA to help you identify when to daub some indexes or rewrite some of the queries to perform better.

    Of course rebuilding indexes and updating statistics is bread and butter and it sounds very much like you're already doing that. The key here (badoom tish) is that just because a table is large (deep) doesn't mean it has to perform badly. This isn't 1970.

    Leave a comment:


  • SimonMac
    replied
    Simple enough for me to understand though?

    Leave a comment:


  • mudskipper
    replied
    I can explain it with smarties

    Leave a comment:


  • DimPrawn
    replied
    Originally posted by SimonMac View Post
    But is it only a temporary performance drop? You mention the indexes, but they are scheduled to be rebuilt anyway, so does this negate the loss of performance
    Rebuilding the indexes after the shrink will move all the pages around again, the DB will then grow much larger during this process. OS Disk fragmentation will get even worse. But if it makes you feel like you're making things better and can invoice why the hell not?

    Leave a comment:


  • LondonManc
    replied
    Originally posted by SimonMac View Post
    No, this is Dynamics Batch history, yeah it is taking a while, only doing a month at a time but making a big improvement on size so far at least.
    Sounds similar to the SSIS batch job history. Had fun with that last year.
    One thing for you to look for - there may be a retention parameter or you might need to set up a job to periodically purge the batch history.

    Leave a comment:


  • SimonMac
    replied
    Originally posted by DimPrawn View Post
    Like I said, shrinking a database will ruin the performance, so it's up to you.
    But is it only a temporary performance drop? You mention the indexes, but they are scheduled to be rebuilt anyway, so does this negate the loss of performance

    Leave a comment:


  • DimPrawn
    replied
    Originally posted by SimonMac View Post
    Its clear in my mind at least

    I am removing data, that bit I am happy with, I want to know if this alone will improve performance of backup/indexing etc or will I need to shrink the database as well
    Like I said, shrinking a database will ruin the performance, so it's up to you.

    Leave a comment:


  • SimonMac
    replied
    Originally posted by DimPrawn View Post
    You seem to be confusing removing data vs shrinking database. By all means remove old data, just shrinking the DB will move all the pages around, causing table and index fragmentation and OS disk fragmentation.
    Its clear in my mind at least

    I am removing data, that bit I am happy with, I want to know if this alone will improve performance of backup/indexing etc or will I need to shrink the database as well

    Leave a comment:


  • SimonMac
    replied
    Originally posted by LondonManc View Post
    Be careful with job history, it takes a fair while to clear down.

    If it's SQL Server (which Dynamics AX tends to sit on), then do you mean the SQL Server job history table? There's a retention parameter which sets the number of days to keep. Reducing this will mean that the clear up process will suddenly dump the extra days - make sure you do this at a quiet time (create some SQL to run after your weekly backup).
    No, this is Dynamics Batch history, yeah it is taking a while, only doing a month at a time but making a big improvement on size so far at least.

    Leave a comment:


  • DimPrawn
    replied
    Originally posted by SimonMac View Post
    Indexes are rebuilt weekly, but if there is less data in the tables, the rebuilt indexes etc will be completed quicker?
    You seem to be confusing removing data vs shrinking database. By all means remove old data, just shrinking the DB will move all the pages around, causing table and index fragmentation and OS disk fragmentation.

    Leave a comment:


  • LondonManc
    replied
    Originally posted by SimonMac View Post
    Not SAP (Dynamics AX), that is exactly what I did, 4 of the biggest tables are the job history from when the system was launched in 2014 and not done with anything since
    Be careful with job history, it takes a fair while to clear down.

    If it's SQL Server (which Dynamics AX tends to sit on), then do you mean the SQL Server job history table? There's a retention parameter which sets the number of days to keep. Reducing this will mean that the clear up process will suddenly dump the extra days - make sure you do this at a quiet time (create some SQL to run after your weekly backup).

    Leave a comment:


  • SimonMac
    replied
    Originally posted by DimPrawn View Post
    Shrinking destroys the performance because it fragments indexes and causes disk fragmentation. You then have to rebuild, which grows the database.
    Indexes are rebuilt weekly, but if there is less data in the tables, the rebuilt indexes etc will be completed quicker?

    Leave a comment:


  • DimPrawn
    replied
    Originally posted by SimonMac View Post
    I saw that article, which is why I mentioned about the database growing over time to undo the work of the shrink, but if the regrowth is the only issue then shrinking the database after doing something so drastic is acceptable given how long it would take for the database to grow again at current rates.

    Would I still notice improvements in the database if I remove data, but don't shrink if my main objective is to increase performance, not reclaim disk space
    Shrinking destroys the performance because it fragments indexes and causes disk fragmentation. You then have to rebuild, which grows the database.

    Leave a comment:


  • SimonMac
    replied
    I saw that article, which is why I mentioned about the database growing over time to undo the work of the shrink, but if the regrowth is the only issue then shrinking the database after doing something so drastic is acceptable given how long it would take for the database to grow again at current rates.

    Would I still notice improvements in the database if I remove data, but don't shrink if my main objective is to increase performance, not reclaim disk space

    Leave a comment:

Working...
X