How can I verify if SHRNK or MOVE will reclaim space?

Hi all,
I need to optimize a 9.2 and a 10.2 database.
I suspect fragmentation to be one of the causes of slowness (some queries do a lot of full table scan), but I want to rebuild only the objects which really contain unused .
How can I verify in advance if an ALTER TABLE SHRINK or ALTER TABLE MOVE will really reclaim free space? I'd like to verify if some segments are good candidates for shrinking rather when do an "ALTER TABLE MOVE" on the whole database...
Is DBMS_SPACE.SPACE_USAGE the only thing I can use?
thanks in advance for every answer.
andrea

Normally I use this package from Tom Kyte to check the space usage of the object.
create or replace procedure show_space
( p_segname in varchar2,
  p_owner   in varchar2 default user,
  p_type    in varchar2 default 'TABLE',
  p_partition in varchar2 default NULL )
-- this procedure uses authid current user so it can query DBA_*
-- views using privileges from a ROLE and so it can be installed
-- once per database, instead of once per user that wanted to use it
authid current_user
as
    l_free_blks                 number;
    l_total_blocks              number;
    l_total_bytes               number;
    l_unused_blocks             number;
    l_unused_bytes              number;
    l_LastUsedExtFileId         number;
    l_LastUsedExtBlockId        number;
    l_LAST_USED_BLOCK           number;
    l_segment_space_mgmt        varchar2(255);
    l_unformatted_blocks number;
    l_unformatted_bytes number;
    l_fs1_blocks number; l_fs1_bytes number;
    l_fs2_blocks number; l_fs2_bytes number;
    l_fs3_blocks number; l_fs3_bytes number;
    l_fs4_blocks number; l_fs4_bytes number;
    l_full_blocks number; l_full_bytes number;
    -- inline procedure to print out numbers nicely formatted
    -- with a simple label
    procedure p( p_label in varchar2, p_num in number )
    is
    begin
        dbms_output.put_line( rpad(p_label,40,'.') ||
                              to_char(p_num,'999,999,999,999') );
    end;
begin
   -- this query is executed dynamically in order to allow this procedure
   -- to be created by a user who has access to DBA_SEGMENTS/TABLESPACES
   -- via a role as is customary.
   -- NOTE: at runtime, the invoker MUST have access to these two
   -- views!
   -- this query determines if the object is a ASSM object or not
   begin
      execute immediate
          'select ts.segment_space_management
             from dba_segments seg, dba_tablespaces ts
            where seg.segment_name      = :p_segname
              and (:p_partition is null or
                  seg.partition_name = :p_partition)
              and seg.owner = :p_owner
              and seg.tablespace_name = ts.tablespace_name'
             into l_segment_space_mgmt
            using p_segname, p_partition, p_partition, p_owner;
   exception
       when too_many_rows then
          dbms_output.put_line
          ( 'This must be a partitioned table, use p_partition => ');
          return;
   end;
   -- if the object is in an ASSM tablespace, we must use this API
   -- call to get space information, else we use the FREE_BLOCKS
   -- API for the user managed segments
   if l_segment_space_mgmt = 'AUTO'
   then
     dbms_space.space_usage
     ( p_owner, p_segname, p_type, l_unformatted_blocks,
       l_unformatted_bytes, l_fs1_blocks, l_fs1_bytes,
       l_fs2_blocks, l_fs2_bytes, l_fs3_blocks, l_fs3_bytes,
       l_fs4_blocks, l_fs4_bytes, l_full_blocks, l_full_bytes, p_partition);
     p( 'Unformatted Blocks ', l_unformatted_blocks );
     p( 'FS1 Blocks (0-25)  ', l_fs1_blocks );
     p( 'FS2 Blocks (25-50) ', l_fs2_blocks );
     p( 'FS3 Blocks (50-75) ', l_fs3_blocks );
     p( 'FS4 Blocks (75-100)', l_fs4_blocks );
     p( 'Full Blocks        ', l_full_blocks );
  else
     dbms_space.free_blocks(
       segment_owner     => p_owner,
       segment_name      => p_segname,
       segment_type      => p_type,
       freelist_group_id => 0,
       free_blks         => l_free_blks);
     p( 'Free Blocks', l_free_blks );
  end if;
  -- and then the unused space API call to get the rest of the
  -- information
  dbms_space.unused_space
  ( segment_owner     => p_owner,
    segment_name      => p_segname,
    segment_type      => p_type,
    partition_name    => p_partition,
    total_blocks      => l_total_blocks,
    total_bytes       => l_total_bytes,
    unused_blocks     => l_unused_blocks,
    unused_bytes      => l_unused_bytes,
    LAST_USED_EXTENT_FILE_ID => l_LastUsedExtFileId,
    LAST_USED_EXTENT_BLOCK_ID => l_LastUsedExtBlockId,
    LAST_USED_BLOCK => l_LAST_USED_BLOCK );
    p( 'Total Blocks', l_total_blocks );
    p( 'Total Bytes', l_total_bytes );
    p( 'Total MBytes', trunc(l_total_bytes/1024/1024) );
    p( 'Unused Blocks', l_unused_blocks );
    p( 'Unused Bytes', l_unused_bytes );
    p( 'Last Used Ext FileId', l_LastUsedExtFileId );
    p( 'Last Used Ext BlockId', l_LastUsedExtBlockId );
    p( 'Last Used Block', l_LAST_USED_BLOCK );
end;
/Read about it completely here.
Aman....

Similar Messages

  • HT1498 How can I find out when a movie will be available for rent?

    How can I find out when a movie will be available for rent?

    You can't. A movie's only available for rental if the copyright holder allows that; nobody except for them and Apple would know when or if a specific movie will be.
    (102388)

  • How can I verify if airdrop (OS Lion) will work on my older (Mid 08) Black macbook?

    Is there a macbook version list that details the mac's that will allow airdrop to work on? I find that late 08 macbooks will apparently work but as I purchased my macbook (black) in July I'm not sure if I should proceed with installing the new OS if all the products will not works.

    MacBook 4.1 is an Early 2008 http://www.everymac.com/systems/apple/macbook/stats/macbook-core-2-duo-2.4-black -13-early-2008-penryn-specs.html
    The Late 2008 MacBooks are Unibody/Aluminum and have the identifier 5.1 http://www.everymac.com/systems/apple/macbook/stats/macbook-core-2-duo-2.4-alumi num-13-late-2008-unibody-specs.html
    Stefan

  • When trying to download yosemite it sais that i do not have enough memory. when i look at my memory use it shows that 111.00gb of space is used by movies but when i go th the movie folder it is empty. how can i remove the non existant movies.

    when trying to download yosemite it sais that i do not have enough memory. when i look at my memory use it shows that 111.00gb of space is used by movies but when i go th the movie folder it is empty. how can i remove the non existant movies.

    Freeing Up Space on The Hard Drive
      1. See Lion/Mountain Lion/Mavericks' Storage Display.
      2. You can remove data from your Home folder except for the /Home/Library/ folder.
      3. Visit The XLab FAQs and read the FAQ on freeing up space on your hard drive.
      4. Also see Freeing space on your Mac OS X startup disk.
      5. See Where did my Disk Space go?.
      6. See The Storage Display.
    You must Empty the Trash in order to recover the space they occupied on the hard drive.
    You should consider replacing the drive with a larger one. Check out OWC for drives, tutorials, and toolkits.
    Try using OmniDiskSweeper 1.8 or GrandPerspective to search your drive for large files and where they are located.
    You will need a minimum of 10-12 GBs of free space to install Yosemite, however, that is a bare minimum and should be at least twice that amount.

  • I downloaded an album on itunes using my new itouch; but it's only allowing me to put three songs at any one time into the music app...how can i get it to just move them all in there?

    i downloaded an album on itunes using my new itouch; but it's only allowing me to put three songs at any one time into the music app...how can i get it to just move them all in there?

    hi philly, thanks for getting back to me, especially on such a busy day.
    I don't think that's quite the issue though. I bought an album and it appears in 'my purchases' within the itunes app. Yet, in order to listen to the music, i must use the 'music' app and in this application, there are only three tracks displayed at any one time from my downloaded album.
    I can 'download all' from the 'my purchases' section but that still doesn't help, it just keeps the last three tracks downloaded in the music app.
    I have the 'icloud' enabled and wondered if it had anything to do with that.
    i have successfully downloaded another full album totally into the music app, but this first album is causing me problems.

  • My old email account was disabled and I can't remember my password - how can I reset my password or move $ to a new itunes/email account?  It seems I must have mis-typed my information because I can't answer the security questions correctly...

    My old email account is disabled and I can't remember my itunes password - how can I reset my password or move $ to a new itunes/email account?  It seems I must have mis-typed my account information because I can't answer the security questions correctly...

    ➡ https://iforgot.apple.com/

  • How can I burn more than 1 movie to a DVD when there is room on the disc for it. Premiere wants to overwrite once 1 movie is burned to the disc

    How can I burn more than 1 movie onto a DVD? Once 1 movie is burned successfully to the disc, I try to burn another movie and Premiere wants to overwrite the first movie. One movie is 1.2 GB, second is 2.3; so there is room on a 4.7 GB DVD-RW.

    susang
    What you report is what it is.
    Each burn to of Timeline content to DVD-VIDEO format on DVD disc results in the disc containing one OpenDVD Folder and one VIDEO_TS Folder.
    Only one VIDEO_TS Folder can be put on a DVD-VIDEO disc even when Premiere Elements is not involved. I have seen that written about online, and I have
    never found a way to overcome what seems to be basic behavior description of DVD-VIDEO..
    Premiere Elements will allow you to write to a disc with content already on it, but only after you give the OK for erasing the disc content before going ahead
    with the burn to.
    If you have several movies, one possibility is to build a Timeline with the movies, use stop markers, and setup disc menus according so that the viewer
    can selectively watch the movies. More on that later if wanted.
    Any questions or need clarification, please ask.
    Thank you.
    ATR

  • Just replaced my iphone 4 with new 4.  restore from icloud is hung on an app I no longer use (password probably expired) how can i get the restore to move on to the next app

    just replaced my iphone 4 with new 4.  restore from icloud is hung on an app I no longer use (password probably expired) how can i get the restore to move on to the next app

    Read another post in the forum about this and it appears this app also installs a profile with a proxy service that you will have to try and delete as well. Check that out.

  • How can i verify my email on my apple id by downloading apps on my iPad mini ?

    I have problem downloading apps on my iPad using apple id. But the problem is my verification e mail. but how can i verify my email ? is that so ? Are there any alternates downloading apps instead of apple id?

    No alternatives, check your spam, junk, trash folders and rescue email account for the verification email.

  • How can I verify credit of an itunes card that has already been redeemed?  My Grandson and I both redeemed itune cards on our shared account about the same time. There isn't a credit balance after his purchase?

    How can I verify credit for an itunes card that has already been redeemed?  My Grandson and I both redeemed itune cards on our shared account about the same time. There isn't a credit balance after his purchase?

    Have you checked the account's purchase history to see if anything could have used up the balance : See your purchase history in the iTunes Store - Apple Support ?
    If there aren't any purchases then try logging out and back into the account (e.g. on your iPad tap on your id in Settings > Stores and then log back in) and see if a balance then shows on it. My account's balance shows at the top right of the store's page on my computer's iTunes, by clicking on my name towards the top right of the iTunes screen, and by logging in to view my account via the Store > View Account menu option. On my iPad devices it shows at the bottom of, for example, the Featured tab in the App Store app under my account id (or you can view your account via Settings > Stores and it should show on the screen that you are taken to)

  • When I try using Airplay to stream from Amazon Prime it tries to use Apple TV music.  How can I get it it stream movies from Amazon Prime?

    When I try using Airplay to stream from Amazon Prime it tries to use Apple TV music.  How can I get it it stream movies from Amazon Prime?

    Welcome to the Apple Community.
    Try the following steps, check whether things are working after each step where appropriate, before trying the next.
    Restart the Apple TV (Settings > General > Restart).
    Restart the Apple TV by removing ALL the cables for 30 seconds.
    Restart your router.
    Reset the Apple TV (Settings > General > Reset > Reset all settings)
    Restore the Apple TV (Settings > General > Reset > Restore)

  • HT4061 How can I restore an iTunes purchased movie that I accidentally deleted. Thank you.

    How can I restore a purchased iTunes movie that I accidentally deleted? Thanks.  BB

    You are not licensed to burn any iTunes video products, regardless of whether it's to a data DVD or a playable DVD.
    See the iTunes Terms & Conditions, Usage Rules v.   "(v) You shall not be entitled to burn video iTunes Products or tone iTunes Products."   Additionally, you are only licensed to use iTunes products on iTunes authorized devices, which DVD players are not.

  • How can I convert my iPhone 5 movies to a DVD to play in DVD players?

    How can I convert my iPhone 5 movies to a DVD to play in DVD players?

    Here's one way:
    https://itunes.apple.com/us/app/video-to-dvd/id569680533?mt=8&ign-mpt=uo%3D2
    Or, you look for software like this:
    http://www.aimersoft.com/how-to-burn/iphone-video-to-dvd.html

  • How can I verify an apple id already created without attaching a credit card?

    how can I verify an apple id already created without attaching a credit card?

    Why do you need to verify it? Have you received an email telling you to click a link to do so? - if so it's very possible that it's a scam designed to trick you into entering your credit card details. If you have received such an email don't follow any links in it. If it's not addressed to you by name it's unlikely to be from Apple.
    You could copy and paste the email into a post here so that we can have a look at it - remove your own email address when you do this.
    If there is some other reason you want to verify the ID please give more details.

  • How can I verify my icloud account on my iphone as I dont have an apple email account

    How can I verify my icloud account on my iphone as I dont have an apple email set up

    Hi Tummy62,
    I apologize that I'm a bit unclear on the exact issue you are having, but if you are having issues setting up iCloud on your iPhone, you may find this page helpful:
    Apple - iCloud - Set Up iCloud
    https://www.apple.com/icloud/setup/ios.html
    Regards,
    - Brenden

Maybe you are looking for

  • How to share music on a single computer document doesn't show music in other account on the computer

    Hello.  I have 2 accounts on my Windows 7 computer and want both to access the same library.  I have followed the instructions for sharing the iTunes Media folder to the public folder.  I have moved the path appropriately on both accounts.  However,

  • Dock won't hide/show after Tiger security update

    I installed the Dec 27 Tiger security update last night (via SW update) and now the dock is behaving badly. I had it set to automatically show/hide, but it would not show anymore after the update. I always install sec updates, so I did also do the pr

  • No audio or access to set AE preferences

    I have no audio during playback in AE CS4.  Using RAM preview, audio is not muted within AE.  Entire program also tends to lock up.  Footage is HD.  Audio fine when running Final Cut.  Master files are QuickTime and AIF.  Unable to access preferences

  • Need assistance with Windows 2008 R2 server BSOD - ATTEMPTED_EXECUTE_OF_NOEXECUTE_MEMORY (fc)

    Need assistance with Windows 2008 R2 server BSOD - ATTEMPTED_EXECUTE_OF_NOEXECUTE_MEMORY (fc) I have a Windows 2008 R2 server which is experiencing random BSOD during the night. This is occurring maybe once or twice a week. I have gathered two Memory

  • Run time error in all standard reports

    Hi Gurus I got a run time error in all standard reports and error as below. Unable to fulfil request for 8296200 bytes of storage space.                                                                                What happened?