Space used size decreased

hi
we got our DB's on SQL server2012 entriprise edition,recently i have ran rebuild index maintenance plan for a DB which is around 350GB as this was taking loads of time and consuming lots of disk space i have killed the process in the middle.As this 
plan was taking loads of time to roll back i have restarted the services and then DB went to INRECOVERY and has taken much time to come back to normal online mode. when i have checked the log after recovery it was showing DB has been recovered with 1 transaction
roll back and iam assuming that is rebuild. After this i have shrinked both LDF and MDF and everthing working fine,But i can see decrease in the SPACEUSED in MDF by 12GB could please some one help me to know the reason for this sudden decrease.
with regards,
Ram

hi
If iam not wrong shrinking MDF  will release it's existing free space to hard disk right,how come the space used for MDF file decreased.
for reference i was using below query to calculate the growth of DB by seeing space used
if exists (select * from tempdb.sys.all_objects where name like '%#dbsize%')
drop table #dbsize
create table #dbsize
(Dbname sysname,dbstatus varchar(50),Recovery_Model varchar(40) default ('NA'), file_Size_MB decimal(30,2)default (0),Space_Used_MB decimal(30,2)default (0),Free_Space_MB decimal(30,2) default (0))
go
insert into #dbsize(Dbname,dbstatus,Recovery_Model,file_Size_MB,Space_Used_MB,Free_Space_MB)
exec sp_msforeachdb
'use [?];
  select DB_NAME() AS DbName,
    CONVERT(varchar(20),DatabasePropertyEx(''?'',''Status'')) ,  
    CONVERT(varchar(20),DatabasePropertyEx(''?'',''Recovery'')),  
sum(size)/128.0 AS File_Size_MB,
sum(CAST(FILEPROPERTY(name, ''SpaceUsed'') AS INT))/128.0 as Space_Used_MB,
SUM( size)/128.0 - sum(CAST(FILEPROPERTY(name,''SpaceUsed'') AS INT))/128.0 AS Free_Space_MB  
from sys.database_files  where type=0 group by type'
go
-------------------log size--------------------------------------
  if exists (select * from tempdb.sys.all_objects where name like '#logsize%')
drop table #logsize
create table #logsize
(Dbname sysname, Log_File_Size_MB decimal(38,2)default (0),log_Space_Used_MB decimal(30,2)default (0),log_Free_Space_MB decimal(30,2)default (0))
go
insert into #logsize(Dbname,Log_File_Size_MB,log_Space_Used_MB,log_Free_Space_MB)
exec sp_msforeachdb
'use [?];
  select DB_NAME() AS DbName,
sum(size)/128.0 AS Log_File_Size_MB,
sum(CAST(FILEPROPERTY(name, ''SpaceUsed'') AS INT))/128.0 as log_Space_Used_MB,
SUM( size)/128.0 - sum(CAST(FILEPROPERTY(name,''SpaceUsed'') AS INT))/128.0 AS log_Free_Space_MB  
from sys.database_files  where type=1 group by type'
go
--------------------------------database free size
  if exists (select * from tempdb.sys.all_objects where name like '%#dbfreesize%')
drop table #dbfreesize
create table #dbfreesize
(name sysname,
database_size varchar(50),
Freespace varchar(50)default (0.00))
insert into #dbfreesize(name,database_size,Freespace)
exec sp_msforeachdb
'use [?];SELECT database_name = db_name()
    ,database_size = ltrim(str((convert(DECIMAL(15, 2), dbsize) + convert(DECIMAL(15, 2), logsize)) * 8192 / 1048576, 15, 2) + ''MB'')
    ,''unallocated space'' = ltrim(str((
                CASE  
                    WHEN dbsize >= reservedpages
                        THEN (convert(DECIMAL(15, 2), dbsize) - convert(DECIMAL(15, 2), reservedpages)) * 8192 / 1048576
                    ELSE 0
                    END
                ), 15, 2) + '' MB'')
FROM (
    SELECT dbsize = sum(convert(BIGINT, CASE  
                    WHEN type = 0
                        THEN size
                    ELSE 0
                    END))
        ,logsize = sum(convert(BIGINT, CASE  
                    WHEN type <> 0
                        THEN size
                    ELSE 0
                    END))
    FROM sys.database_files
) AS files
    SELECT reservedpages = sum(a.total_pages)
        ,usedpages = sum(a.used_pages)
        ,pages = sum(CASE  
                WHEN it.internal_type IN (
                        202
                        ,204
                        ,211
                        ,212
                        ,213
                        ,214
                        ,215
                        ,216
                    THEN 0
                WHEN a.type <> 1
                    THEN a.used_pages
                WHEN p.index_id < 2
                    THEN a.data_pages
                ELSE 0
                END)
    FROM sys.partitions p
    INNER JOIN sys.allocation_units a
        ON p.partition_id = a.container_id
    LEFT JOIN sys.internal_tables it
        ON p.object_id = it.object_id
) AS partitions'
if exists (select * from tempdb.sys.all_objects where name like '%#alldbstate%')
drop table #alldbstate  
create table #alldbstate  
(dbname sysname,
DBstatus varchar(55),
R_model Varchar(30))
--select * from sys.master_files
insert into #alldbstate (dbname,DBstatus,R_model)
select name,CONVERT(varchar(20),DATABASEPROPERTYEX(name,'status')),recovery_model_desc from sys.databases
--select * from #dbsize
insert into #dbsize(Dbname,dbstatus,Recovery_Model)
select dbname,dbstatus,R_model from #alldbstate where DBstatus <> 'online'
insert into #logsize(Dbname)
select dbname from #alldbstate where DBstatus <> 'online'
insert into #dbfreesize(name)
select dbname from #alldbstate where DBstatus <> 'online'
select  
d.Dbname,d.dbstatus,d.Recovery_Model,
(file_size_mb + log_file_size_mb) as DBsize,
d.file_Size_MB,d.Space_Used_MB,d.Free_Space_MB,
l.Log_File_Size_MB,log_Space_Used_MB,l.log_Free_Space_MB,fs.Freespace as DB_Freespace
from #dbsize d join #logsize l  
on d.Dbname=l.Dbname join #dbfreesize fs  
on d.Dbname=fs.name
order by Dbname

Similar Messages

  • Function module to find out DATA BASE size, free space, used size

    Is there any function module to find out DATA BASE , free space, used size
    FM that gives all the details of the Date base
    what data base, what is the size, free space, used space etc...
    instead of writing case by case for each data base. based on  CASE SY-DBSYS.

    Hi,
    Check this FM:
    DB02_ORA_SELECT_DBA_SEGMENT
    alternatively u can check the tcode: DB02
    thanks|
    Mahesh

  • Backup Space Used Will Not Decrease When Photos Deleted

    I use the cloud to back up my iPhone 5.  I noticed that when I delete or transfer photos off of my phone/delete, and then do another back up, the amount used for that back up does not decrease.  I would think taking photos off, which are backed up to the cloud, would decrease the amount of cloud space used since they no longer are being backed up as they are off the phone.
    For now, I am deleting my back up after I remove the photos from the phone and making a fresh back up, which of course would not include the photos I removed, and consequently taking up less space in the cloud.
    Explain please.

    Apple states that iCloud keeps the 3 most recent back ups. You would therefore not expect the size of your back up file to be reduced immediately.

  • How can free + used space tbs size, can someone explain

    Hi Gurus
    Can someone explain this, How can free + used space in a tablespace can be greater than size of a tablespace. What am I missing here . Thanks a lot .
    I am on 10.2.0.1, HP-UX
    14:38:52 SQL> select owner,sum(bytes), sum(BYTES) /1024/1024 "MB" from dba_segments where tablespace
    name='USERDB1ADATA' group by owner;
    OWNER SUM(BYTES) MB
    USERDB1A 839680000 800.78125
    1 row selected.
    14:40:42 SQL> select bytes, BYTES /1024/1024 "MB" from dba_data_files where tablespace_name='USERDB1
    A_DATA';
    BYTES MB
    3758096384 3584
    1 row selected.
    14:40:42 SQL> select sum(bytes) , sum(BYTES) /1024/1024 "MB"from dba_free_space where tablespace_nam
    e='USERDB1A_DATA';
    SUM(BYTES) MB
    3067412480 2925.3125
    1 row selected.
    14:40:43 SQL> select 839680000 + 3067412480 "used + free space" from dual;
    used + free space
    3907092480
    1 row selected.
    New DBA

    Good point, Howard, about the recycle bin. So I cleaned up, recreated the table, filled it, dropped it but did not purge it, and ...
    SQL> create table test.x tablespace test as select * from dba_objects where 1=2;
    Table created.
    SQL> insert into test.x select * from dba_objects;
    12617 rows created.
    SQL> commit;
    Commit complete.
    SQL> drop table test.x;
    Table dropped.
    SQL> with
      2  dbf_size as (select sum(bytes) size_
      3                 from dba_data_files where tablespace_name='TEST'),
      4  dbf_free as (select sum(bytes) free_
      5                 from dba_free_space where tablespace_name='TEST'),
      6  dbf_used as (select sum(bytes) used_
      7                 from dba_segments where tablespace_name='TEST')
      8  select size_, free_, used_, (size_ - free_ - used_) left_
      9         from dbf_size, dbf_free, dbf_used
    10  /
         SIZE_      FREE_      USED_      LEFT_
       5242880    5177344    2162688   -2097152
    SQL>and then I played around with my SQL and came up with
    WITH
    dbf_size AS (SELECT SUM(bytes) size_
                   FROM dba_data_files
                  WHERE tablespace_name='TEST'),
    dbf_free AS (SELECT SUM(bytes) free_
                   FROM dba_free_space
                  WHERE tablespace_name='TEST'),
    dbf_used AS (SELECT SUM(bytes) used_
                   FROM dba_segments
                  WHERE tablespace_name='TEST'),
    dbf_fbin AS (SELECT SUM(bytes) fbin_
                   FROM dba_segments
                  INNER JOIN
                        dba_recyclebin
                     ON (tablespace_name=ts_name
                         AND segment_name=object_name)
                  WHERE tablespace_name='TEST')
    SELECT      size_, -- tablespace size
         free_, -- free space reported
         used_, -- segment space used
         fbin_, -- segment space in recycle bin
         (size_ - free_ - used_ + fbin_) left_ -- 64K overhead per data file
      FROM      dbf_size, dbf_free, dbf_used, dbf_fbin
    /which does
    SQL> WITH
      2  dbf_size AS (SELECT SUM(bytes) size_
      3                 FROM dba_data_files
      4                WHERE tablespace_name='TEST'),
      5  dbf_free AS (SELECT SUM(bytes) free_
      6                 FROM dba_free_space
      7                WHERE tablespace_name='TEST'),
      8  dbf_used AS (SELECT SUM(bytes) used_
      9                 FROM dba_segments
    10                WHERE tablespace_name='TEST'),
    11  dbf_fbin AS (SELECT SUM(bytes) fbin_
    12                 FROM dba_segments
    13                INNER JOIN
    14                      dba_recyclebin
    15                   ON (tablespace_name=ts_name
    16                       AND segment_name=object_name)
    17                WHERE tablespace_name='TEST')
    18  SELECT     size_,
    19     free_,
    20     used_,
    21     fbin_,
    22     (size_ - free_ - used_ + fbin_) left_
    23    FROM     dbf_size, dbf_free, dbf_used, dbf_fbin
    24  /
         SIZE_      FREE_      USED_      FBIN_      LEFT_
       5242880    5177344    2162688    2162688      65536
    SQL> alter tablespace test add datafile 'C:\ORACLE\ORADATA\XE\TEST2.DBF' size 5m;
    Tablespace altered.
    SQL> WITH
      2  dbf_size AS (SELECT SUM(bytes) size_
      3                 FROM dba_data_files
      4                WHERE tablespace_name='TEST'),
      5  dbf_free AS (SELECT SUM(bytes) free_
      6                 FROM dba_free_space
      7                WHERE tablespace_name='TEST'),
      8  dbf_used AS (SELECT SUM(bytes) used_
      9                 FROM dba_segments
    10                WHERE tablespace_name='TEST'),
    11  dbf_fbin AS (SELECT SUM(bytes) fbin_
    12                 FROM dba_segments
    13                INNER JOIN
    14                      dba_recyclebin
    15                   ON (tablespace_name=ts_name
    16                       AND segment_name=object_name)
    17                WHERE tablespace_name='TEST')
    18  SELECT     size_, -- tablespace size
    19     free_, -- free space reported
    20     used_, -- segment space used
    21     fbin_, -- segment space used in recycle bin
    22     (size_ - free_ - used_ + fbin_) left_
    23    FROM     dbf_size, dbf_free, dbf_used, dbf_fbin
    24  /
         SIZE_      FREE_      USED_      FBIN_      LEFT_
      10485760   10354688    2162688    2162688     131072Message was edited by:
    Hans Forbrich
    Cleaned up the script and tested with second data file added to verify LMT overhead.

  • Why is my amount of space used different from my Creative Cloud Files Folder size?

    Why is my amount of 'space used' different from my Creative Cloud Files Folder size? CC is telling me I'm using 93% (18.6GB of 20GB) but my CC File Folder only contains 13.42GB?  

    Have you checked the "Archive" section on the Creative.adobe.com website ?
    When you delete the files then they are moved to the "Archive" from where you can delete the content permanently.
    Clear the Archive section and then check.

  • Difference in size of Creative Cloud Files synced folder and online file space used

    Anyone have any idea why Creative Cloud says my space used online is 50% larger than the total file size in my local "Creative Cloud Files" folder?  I've logged in and out of my account, restarted the Creative Cloud app, checked my archive online through the browser, and emptied my archive online.

    I have replied to your private message about resolving this issue.

  • How to reclaim the space used for LOBSEGMENT, which is growing fast

    Hi,
    DB version 10.2.0.2
    OS RHEL v4
    Envi RAC on ASM
    On the production, in one of the schemas (PR_AA) on the tablespace PR_AA, i have
    1) a table (Table1) which has 3 columns of CLOB datatype. Current size of this table is 65 GB.
    2) Two LOBSEGMENTS 85GB + 25GB =110GB
    3) about 10 Indexes of Table1 are of 15 to 17 GB
    Table1 is being purged on a daily basis, but still the tablespace is growing like anything ( now the over all size of the tablespace is itself 190GB).
    What i need is,
    Q1 . Ways to reclaim the purged space from the table1.
    Q2. How to shrink the table/ tablespace? Is it possible to do it online without impacting the users/business?
    Q3. How to shrink/maintain LOBSEGMENTS space, that is , how to control the size or reclaim the space from LOBSEGMENT after the daily purge on the Table1?
    Quick help is much appreciated and thank you in advance.
    Regards
    BPL666

    Check the below metalink note and you should be able to resolve all issue (Check atucal size, Calculate space used,Move LOBDATA..etc)
    Master Note - RDBMS Large Objects (LOBs) [ID 1268771.1]
    Hope this helps,
    Regards
    http://www.oracleracexpert.com
    Oracle RMAN New Features in 11g
    http://www.oracleracexpert.com/2011/12/oracle-recovery-managerrman-new.html
    RMAN Incrementally updated backups
    http://www.oracleracexpert.com/2011/12/rman-incrementally-updated-backups.html
    Edited by: Satishbabu Gunukula on Dec 22, 2011 1:11 PM

  • Determining the space used by data in a table at the granularity of bytes

    The SPACE_USAGE procedure of DBMS_SPACE package
    is meant for knowing space table with auto segment
    space management.
    It gives out 4 types of values fs1_blocks to
    fs4_blocks as the number of blocks which are filled
    25%, 50%, ....
    I tried it with different number of records (including)
    and empty table) but all 4 fields are always output as
    zero.
    Basically my aim is to know the actual amount of space
    used by my data in the table for both auto segment
    allocation and non auto mode.

    To have this kind of information I've used the function
    DBMS_SPACE.UNUSED_SPACE, that reporting:
    TOTAL_BLOCKS - data allocation space (in blocks)
    TOTAL_BYTES - data allocation space (in bytes)
    UNUSED_BLOCKS - allocated space but not used (in blocks)
    UNUSED_BYTES - allocated space but not used (in bytes)
    The difference between TOTAL_BYTES and UNUSED_BYTES is the REAL SIZE of your data.
    I don't know if you can use the same function for table with auto segment space management.
    Bye L.

  • Steps to Increase / adding New Table Space using BR TOOLS

    Hi
    Can Anyone Tell me the Step by Step Process for Increasing / Adding New Table Space using BRTOOLS.
    Any Demos/Blogs will be appreciated.
    Thanks in Advance.
    Rg
    Dan

    Hi Dan,
    <u><b>Adding a datafile using BRTOOLS</b></u>
    1) su – <b>ora<sid></b>
    2) start <b>brtools</b>
    3) Select option <b>2 -- Space management</b>
    4) Select option <b>1 -- Extend tablespace</b>
    5) Select option <b>3 --Tablespace name (specify tablespace name) and say continue(c- cont)</b>
    6) Select option <b>3 – New data file to be added and return</b>
    7) Select option <b>5 -- Size of the new file in MB (specify the size of the file) and say continue</b>
    regards,
    kanthi

  • Used Space is much higher than actual space used in the partition

    Hi All,
    I am facing space problem in oracle Linux 5.3.
    The parition /oradata is showing Used space as 379 GB when checked with df -TH command and when i go to partition and check space with du -sh command it is showing 280 GB.
    How could i reclaim the space.
    [orah@hih oracle]$ df -TH
    Filesystem Type Size Used Avail Use% Mounted on
    /dev/sda3 ext3 16G 1.0G 14G 7% /
    /dev/sda4 ext3 11G 2.9G 6.8G 31% /usr
    /dev/sdb5 ext3 11G 158M 9.5G 2% /tmp
    /dev/sdb3 ext3 51G 189M 48G 1% /orasig
    /dev/sdb2 ext3 11G 277M 9.4G 3% /var
    /dev/sdb1 ext3 71G 12G 56G 17% /oracle
    /dev/sda1 ext3 104M 16M 83M 17% /boot
    tmpfs tmpfs 26G 9.6M 26G 1% /dev/shm
    /dev/sdc ext3 529G 379G 140G 74% /oradata
    /dev/sdd ext3 529G 401G 128G 76% /orabkp
    /dev/sde ext3 212G 197G 14G 94% /oraprod1
    /dev/sdf ext3 119G 73G 45G 63% /stage
    Rgds,
    Alig

    What is your output of df -h?
    -H uses powers of 1000, not 1024. Computer memory uses binary logic based on the power of 2 (2^10 = 1024, 8 * 8 * 8 * 2 = 1024)
    Anyway, df and du measure different things:
    "du" reports the space used by files and folders
    "df" reports the space used by the file system, which includes the overhead for journals and inode tables.
    If a file is open by a user and the same file is deleted then df and du will report different output.
    A reboot of the system should align df and du output more closely.

  • Using TRUNCATE to free space used by CLOB/BLOB

    Hi ,
    Can we free the complete space used by a CLOB or BLOB by issuing a TRUNCATE command on the table containg these large objects?

    Sorry about my loose terminology - yes I did mean a sparse bundle. Yes if the backup is created on a local disk, it uses ordinary folders. If it is first created over a network, then it creates a sparse bundle. having created the sparse bundle, you can then connect the disk directly for speeding up the initial backup or a major restore, but also connect remotely for routine incremental backups or minor restores.
    It sounds like the type of sparse bundle created may depend on circumstances. In my case I am backing up from a laptop onto a partition on my desktop machine running Leopard 10.5.2 and when I grew the partition, although the Time Machine preference pane saw the extra space, when it came to a backup I got an error message saying there was not enough space and reporting the original size. Deleting and starting over again fixed this.
    It is possible that in other circumstances a disk attached to a Time Capsule or elsewhere might get a sparse bundle with different parameters.
    Incidentally, I tried copying my old backup sparse bundle onto another drive, deleting it and letting Time Machine create a new sparse bundle on my grown partition and copying the contents from the old one into the new one. Time Machine refused to work with it, so I lost my old backups.
    What we need is a Time Machine Utility to manipulate these files, copy them, move backups from direct folders to sparse bundles etc. Ideally Apple would produce this, but I would be willing to pay a shareware fee for that.

  • HT204264 How do I limit the amount of space used by photos on my phone - now that I turned iCloud on it is taking over my phone

    How do I limit the amount of space used by photos on my phone - now that I turned iCloud on it is taking over my phone

    Hello Maahk,
    Welcome to the Apple Support Communities!
    I understand that you would like to optimize your Photos storage. If you are using iCloud Photo Library on your iPhone, please read over the information in the attached article. 
    iCloud Photo Library FAQ - Apple Support
    Can I use iCloud Photo Library to save space on my device?
    iCloud Photo Library automatically keeps all your photos and videos in the original, high-resolution version. Follow these steps to choose how you store your photos and videos on your device:
    In iOS, tap Settings > iCloud > Photos or Settings > Photos & Camera, then select a storage setting.
    In OS X, click Photos > Preferences > iCloud, then select a storage setting. 
    If you turn on Optimize [device] Storage, iCloud Photo Library will automatically manage the size of your library on your device, so you can make the most of your device's storage and access more photos than ever. All of your original, full-resolution photos and videos are stored in iCloud while device-size versions are kept on your device. You can download the original photos and videos over Wi-Fi or cellular when you need them. 
    If you turn on Download Originals, iCloud Photo Library will keep your original, full-resolution photos and videos in iCloud and on your device. Download Originals is the default setting for iOS devices with the free 5 GB storage plan and for all Mac devices.
    Have a great day,
    Joe

  • Twice as much disk space used on external HD for TM than internal HD

    Disk Utility shows the amount of disk space used by TM as 86 GB whereas the HD only shows 45 GB used. Also, the number of files and folders have nearly doubled in size. This from only two days of using TM.
    My Seagate FreeAgent Go External Hard Drive for Mac - 500GB, USB 2.0, FireWire 800, FireWire 400 external hard drive has been partitioned into two segments, one for TM, the other for SuperDuper.

    larry lund wrote:
    Disk Utility shows the amount of disk space used by TM as 86 GB whereas the HD only shows 45 GB used. Also, the number of files and folders have nearly doubled in size. This from only two days of using TM.
    My Seagate FreeAgent Go External Hard Drive for Mac - 500GB, USB 2.0, FireWire 800, FireWire 400 external hard drive has been partitioned into two segments, one for TM, the other for SuperDuper.
    Since TM keeps previous version of things you've changed or deleted, in addition to everything currently on your system, yes, it will use more space.
    But to be twice the size in two days is clearly not right. Chris is probably correct, that TM has been backing-up the SuperDuper "clone" as well. If so, you can delete the backups of it -- see #12 in the Frequently Asked Questions *User Tip,* also at the top of this forum.
    If that's not the case, see #9 there for a way to find out what's taking up so much space. If you find things being backed-up that you don't recognize, post back with the name(s) and location(s); somebody here will likely know what they are.

  • Space used by a statspack snapshot

    Is there an easy way to calculate the disk space used by 1 statspack snapshot?
    Thanks,
    Mark

    values from dba_extents will get you a reasonable answer. One caution though - if you use a DELETE then run more snapshots you will find some interesting answers. Because delete does not free up the blocks they way a truncate command does.
    I just recommend getting an idea of the sizes without having the delete command come into play on the stats$ tables. Otherwise, you will need some other techniques to get storage.
    If you regularly analyze your database including these statspack tables you can capture the avg_row_len and num_rows from the dba_tables view and record this into a logging table that you can run comparisons over time.

  • I moved my year old emails to my Archive box to save iCloud space, when I did that my space used went from 450mb to 990mb?

    I moved my year old emails to my Archive box to save iCloud space, when I did that my space used went from 450mb to 990mb? Like I doubled the amount in my inbox? only they definitely moved not copied from my inbox.

    I cannot find this 300GB "Backup" in the Finder, only in the Storage info when I check "About This Mac".
    You are probably using Time Machine to backup your MacBook Pro, right? Then the additional 300 GB could be local Time Machine snapshots.  Time Machine will write the hourly backups to the free space on your hard disk, if the backup drive is temporarily not connected. You do not see these local backups in the Finder, and MacOS will delete them, when you make a regular backup to Time Machine, or when you need the space for other data.
    See Pondini's page for more explanation:   What are Local Snapshots?   http://pondini.org/TM/FAQ.html
    I have restarted my computer, but the information remains the same. How do I reclaim the use of the 300GB? Why is it showing up as "Backups" when it used to indicate "Photos"? Are my photos safe on the external drive?
    You have tested the library on the external drive, and so your photos are save there.  
    The local TimeMachine snapshot probably now contains a backup of the moved library.  Try, if connecting your Time Machine drive will reduce the size of your local Time Machine snapshots.

Maybe you are looking for