# Bug with DBA\_FREE\_SPACE usage

**URL:** <https://forums.toadworld.com/t/bug-with-dba-free-space-usage/51420>\
**Category:** Toad for Oracle & DevOps Toolkit\
**Created:** [November 5, 2020, 5:33am UTC](https://forums.toadworld.com/t/bug-with-dba-free-space-usage/51420 "2020-11-05T05:33:20Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![damir.vadas\_250](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/damir.vadas_250/32/37_2.png) [@damir.vadas\_250](https://forums.toadworld.com/u/damir.vadas_250)\
**Post date:** [November 5, 2020, 5:33am UTC](https://forums.toadworld.com/t/bug-with-dba-free-space-usage/51420/1 "2020-11-05T05:33:20Z")

</div>

Toad 13.3.0.181 x64 (client 19.3 x64)  
When you want to see free space in tablespace Toad is showing data from DBA\_FREE\_SPACE, what is wrong...as tablespace may be enlarged...and if is not, this is misleading data.  
Example from Toad:  
 ![image](https://global.discourse-cdn.com/quest/original/2X/3/35c742b3fe69c3223684144e80d6e6e778014a2f.png)  
Real situation:  
`TABLESPACE_NAME MAX_MB CURR_alloc_MB CURR_used_MB	CURR_free_MB % CURR_free_MB MAX_free_MB % MAX_free_MB`  
`---------------------------------------- ---------------- ---------------- ---------------- ---------------- -------------- ---------------- -------------`  
`SOLVIT 819.200 641.024 640.876 **148** 0,023 **178.324** 21,768`  
So free space has to be calculated as **max\_size-curr\_occupied** and not curr\_allocated-curr\_occupied.

Hope this helps.

P.S.  
Where has courier font gone for formatting bar in post?

---

<div class="post-metadata">

**Author:** ![JohnDorlon](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/johndorlon/32/9997_2.png) [@JohnDorlon](https://forums.toadworld.com/u/JohnDorlon)\
**Post date:** [November 5, 2020, 3:19pm UTC](https://forums.toadworld.com/t/bug-with-dba-free-space-usage/51420/2 "2020-11-05T15:19:27Z")

</div>

Hi Damir,

Thanks for the feedback. Can you show me the SQL that produced the output below? Also, you are making reference to curr\_occupied and curr\_allocated that I don't see anywhere.

`TABLESPACE_NAME MAX_MB CURR_alloc_MB CURR_used_MB CURR_free_MB % CURR_free_MB MAX_free_MB % MAX_free_MB`  
`---------------------------------------- ---------------- ---------------- ---------------- ---------------- -------------- ---------------- -------------`  
`SOLVIT 819.200 641.024 640.876 **148** 0,023 **178.324** 21,768`

And I have no idea about Courier. Toad World has been behaving weird lately (when scrolling at least), that's for sure.

---

<div class="post-metadata">

**Author:** ![damir.vadas\_250](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/damir.vadas_250/32/37_2.png) [@damir.vadas\_250](https://forums.toadworld.com/u/damir.vadas_250)\
**Post date:** [November 9, 2020, 5:29am UTC](https://forums.toadworld.com/t/bug-with-dba-free-space-usage/51420/3 "2020-11-09T05:29:35Z")

</div>

clear computes  
clear breaks

break on report;  
compute sum of curr\_alloc\_MB free\_MB Max\_MB used\_MB max\_free\_MB on report;

col free\_MB for 999G999G999G990 heading CURR\_free\_MB  
col used\_MB for 999G999G999G990 heading CURR\_used\_MB  
col curr\_alloc\_MB for 999G999G999G990 heading CURR\_alloc\_MB  
col max\_MB for 999G999G999G990  
col max\_free\_MB for 999G999G999G990 heading MAX\_free\_MB  
col perc\_free\_MB for 9990D990 HEADING "% MAX\_free\_MB"  
col perc\_CURR\_free\_MB for 9990D990 HEADING "% CURR\_free\_MB"

PROMPT Tablespace size without TEMP  
with F as (  
select f.tablespace\_name,  
round(SUM(f.Bytes)/1024/1024) free\_MB  
from DBA\_FREE\_SPACE f  
group by f.tablespace\_name  
),  
d as (  
select d.tablespace\_name,  
round(SUM(d.Bytes)/1024/1024) curr\_alloc\_MB  
from DBA\_DATA\_FILES d  
group by d.tablespace\_name  
),  
a as (  
select d.tablespace\_name,  
round(SUM(greatest(d.maxBytes,d.Bytes))/1024/1024) max\_MB  
from DBA\_DATA\_FILES d  
group by d.tablespace\_name  
)  
select d.tablespace\_name,  
a.MAX\_MB,  
d.curr\_alloc\_MB,  
d.curr\_alloc\_MB-nvl(f.free\_MB,0) used\_MB,  
nvl(f.free\_MB,0) free\_MB,  
(1-(curr\_alloc\_MB-nvl(f.free\_MB,0))/curr\_alloc\_MB)\*100 perc\_CURR\_free\_MB,  
a.MAX\_MB-d.curr\_alloc\_MB+nvl(f.free\_MB,0) max\_free\_MB,  
(1-(d.curr\_alloc\_MB-nvl(f.free\_MB,0))/a.MAX\_MB)\*100 perc\_free\_MB  
from d,f,a  
where d.tablespace\_name=f.tablespace\_name (+)  
and a.tablespace\_name=d.tablespace\_name  
order by d.tablespace\_name;

---

<div class="post-metadata">

**Author:** ![JohnDorlon](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/johndorlon/32/9997_2.png) [@JohnDorlon](https://forums.toadworld.com/u/JohnDorlon)\
**Post date:** [November 9, 2020, 6:14pm UTC](https://forums.toadworld.com/t/bug-with-dba-free-space-usage/51420/4 "2020-11-09T18:14:06Z")

</div>

Oh I see what you mean.

Yes, in the Schema Browser, the "Free" column shows only free space of what is currently allocated. It does not include autoextend.

However, there is a column "% Used of Max" that does include autoextend. I realize that is percent and not MB.

 ![image](https://global.discourse-cdn.com/quest/original/2X/b/bc4de27461ace321b68fbeaf7aa4633d012a2a23.png)

---

<div class="post-metadata">

**Author:** ![damir.vadas\_250](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/damir.vadas_250/32/37_2.png) [@damir.vadas\_250](https://forums.toadworld.com/u/damir.vadas_250)\
**Post date:** [November 9, 2020, 11:59pm UTC](https://forums.toadworld.com/t/bug-with-dba-free-space-usage/51420/5 "2020-11-09T23:59:34Z")

</div>

I have sent another picture where this is wrongly presented...in toad

Lp Damir

---

<div class="post-metadata">

**Author:** ![JohnDorlon](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/johndorlon/32/9997_2.png) [@JohnDorlon](https://forums.toadworld.com/u/JohnDorlon)\
**Post date:** [November 10, 2020, 2:59am UTC](https://forums.toadworld.com/t/bug-with-dba-free-space-usage/51420/6 "2020-11-10T02:59:18Z")

</div>

I don't think it is wrong. It shows the sum of all unused space which is currently allocated.

I understand that you find it misleading because you expect it to include space that could be allocated via auto extend, but I think it could be equally misleading if it included all of the potentially allocated space (via tablespace auto extend).

I could add another line in that display to include that information too.

To be honest, I never have been a fan of that "free space" tab. That whole business of "# of pieces", smallest, largest, etc, goes back to the dictionary-managed tablespace days, when fragmentation mattered (or, some thought it did).

---

<div class="post-metadata">

**Author:** ![NormTeamT](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/normteamt/32/53_2.png) [@NormTeamT](https://forums.toadworld.com/u/NormTeamT)\
**Post date:** [November 10, 2020, 7:08am UTC](https://forums.toadworld.com/t/bug-with-dba-free-space-usage/51420/7 "2020-11-10T07:08:25Z")

</div>

Good Morning from lockdown 2!

I once wrote an sql script as part of a Nagios monitoring system, to do exactly this -- how much space is used out of everythingvthat can be allocated, including autoextend.

It was a nightmare. There were tablespaces where only some files were in autoextend mode which needed to be considered -- and all in one single sql statement. I eventually got it working.

Then a database ran out of space! Some of he various databases using this particular array had been set up to autoextend the full amount of the array, as if they were the only database. My sql happily reported that they were fine, until the crash.

If two or more databases share an array, all bets are off with autoextend!

Right, back to lockdown!

Cheers,  
Norm.

---

<div class="post-metadata">

**Author:** ![damir.vadas\_250](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/damir.vadas_250/32/37_2.png) [@damir.vadas\_250](https://forums.toadworld.com/u/damir.vadas_250)\
**Post date:** [November 17, 2020, 7:40am UTC](https://forums.toadworld.com/t/bug-with-dba-free-space-usage/51420/8 "2020-11-17T07:40:28Z")

</div>

> [@NormTeamT](#):
>
> Then a database ran out of space!

I do not understand what this has to do with what I wrote.  
OS file space is something that must be separately monitor or setup but certainly correctly calculated.  
But if you allow that tablespace grow in size more that there is real OS file space, this is wrong setup and nothing can help you.  
Also if you overload file system (saw even much more often than pure space problem) it is again bad file space setup-nothing with Oracle neither Toad.

---

<div class="post-metadata">

**Author:** ![NormTeamT](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/normteamt/32/53_2.png) [@NormTeamT](https://forums.toadworld.com/u/NormTeamT)\
**Post date:** [November 17, 2020, 8:25am UTC](https://forums.toadworld.com/t/bug-with-dba-free-space-usage/51420/9 "2020-11-17T08:25:39Z")

</div>

Hi Damir,

it was an anecdotal tale of how it's possible to be monitoring something to the n'th degree, and still get borked by something outwith your monitoring.

At the time, we had a huge array of disc for database use. Every database lived in it. Multiple DBAs set up the databases with autoextend but some used unlimited maximum size.

Turned out that while we had monitoring of the array as well as the databases, there was (allegedly) a problem/bug in the array monitoring so the databases extended enough to fill it.

Monitoring the database usage, while considering autoextend didn't prevent the failure.

We switched to OEM back then to monitor both.

Cheers,  
Norm. [TeamT]

---

<div class="post-metadata">

**Author:** ![damir.vadas\_250](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/damir.vadas_250/32/37_2.png) [@damir.vadas\_250](https://forums.toadworld.com/u/damir.vadas_250)\
**Post date:** [March 21, 2024, 4:50am UTC](https://forums.toadworld.com/t/bug-with-dba-free-space-usage/51420/10 "2024-03-21T04:50:37Z")

</div>

@Norm,  
Ok I see. I was a little bit too direct... **sorry for that**.

Now for the end of all scenarios where "dba\_free\_space " is used to see free space.  
From oracle docu:

> **If a data file (or entire tablespace) is offline in a locally managed tablespace, you will not see any extent information**.  
> **If an object has extents in an online file of the tablespace, u will see extent information about the offline data file**.  
> **However, if the object is entirely in the offline file, a query of this view will not return any records.**  
> **If a data file does not have any free space, you will not see a row for the data file in this view.**

Do you see how far it can goes and make calculation of tablespace free space complicated (with or without extensible)
