Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesFirebird SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 6th, 2006, 01:06 PM
kcengiz kcengiz is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Posts: 2 kcengiz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 30 m 3 sec
Reputation Power: 0
Database file size problem

Hi I am Kadir, I am new firebird user. But i have got a problem. my problem is sample database creating and i have got table, this table has got ten field.
i enter 100.000 record added database file size 20 Mb exist. then i delete this records. but my database file size is still 20 Mb. why file size is not decrase.
i do this record add-delete operating firebird odbc driver with visual basic 6.0.

i am sory my bad english
thank you very much your help.

Reply With Quote
  #2  
Old December 6th, 2006, 04:52 PM
annaVonSima annaVonSima is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Posts: 5 annaVonSima User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 24 m 16 sec
Reputation Power: 0
shrink DB

To shrink the database just back it up then restore it replacing the existing database.

Quote:
Originally Posted by kcengiz
Hi I am Kadir, I am new firebird user. But i have got a problem. my problem is sample database creating and i have got table, this table has got ten field.
i enter 100.000 record added database file size 20 Mb exist. then i delete this records. but my database file size is still 20 Mb. why file size is not decrase.
i do this record add-delete operating firebird odbc driver with visual basic 6.0.

i am sory my bad english
thank you very much your help.

Reply With Quote
  #3  
Old December 7th, 2006, 02:14 AM
upscene upscene is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 223 upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 7 h 14 m 50 sec
Reputation Power: 8
Firebird will re-use the space that has become available in the file.

The reason that your file doesn't "shrink", is that files simply cannot shrink, they can only become larger. Whenever some application creates a smaller file, it will re-create the file and remove the old file.

Obviously, for a database, this doesn't make sense. You don't want to delete the database file and re-create a new one, just to free up some disk space. Imagine Firebird doing this every now and then on huge files like 40 or 100 Gb. Instead, it will re-use empty space inside the file.

All in all: nothing to worry about.

Martijn Tonies
Database Workbench - development tool for Firebird and more!
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com
__________________
Martijn Tonies
Database Workbench: developer IDE for Firebird, MySQL, InterBase, MSSQL Server and Oracle
Upscene Productions
http://www.upscene.com

Reply With Quote
  #4  
Old December 7th, 2006, 12:27 PM
kcengiz kcengiz is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2006
Posts: 2 kcengiz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 30 m 3 sec
Reputation Power: 0
I ask you my question agein

1- I create sample database file (with ibexpert)
2- I create table in the database
3- I create ten field in the table
4- now database size ~3mb
5- I adding 100000 record in the table with VB6 and ODBC
6- now database size is 20 mb
7-I delete this 100000 record with VB6 and ODBC
8-now database size is steel 20mb
9- why database size is not 2 mb ?

sory bad english language

Reply With Quote
  #5  
Old December 8th, 2006, 02:08 AM
upscene upscene is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 223 upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 7 h 14 m 50 sec
Reputation Power: 8
Read the message I posted earlier, it explains why this happens.

Martijn Tonies
Database Workbench - development tool for Firebird and more!
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com

Reply With Quote
  #6  
Old January 10th, 2007, 03:52 AM
TheMuffinMan TheMuffinMan is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 4 TheMuffinMan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 sec
Reputation Power: 0
Firebird database size problems

I have read through the previous response.

My problem is similar, we are using a firebird database (new V2 release SuperServer on Fedora Core 4) to store images that are being sampled from a camera. There are about 100 images (each image is 50 ~ 70KB) inserted per second. Obviously we know this will keep the database expanding, so we have created an application that runs on the database server which removes the old images. The app is designed to keep a certain amount of images within the database...say at 50,000 images.

The problem we are having is that the database keeps expanding. it is not constant, but it is definitely increasing. It started at about 4.6 GB, remained there for about 2 hours, then increased to 9.6GB... this stayed constant overnight for about 10 hours. Today the size increased to 11GB and then 33GB in 1.5 hours.

We understand the database will not decrease in size, and checking with the app on the server there have never been more than 60,000 images at one time in the DB. So why would the file keep on expanding?

This is a very important project and it is imperative that we solve this problem.

Reply With Quote
  #7  
Old January 10th, 2007, 03:59 AM
upscene upscene is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 223 upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 7 h 14 m 50 sec
Reputation Power: 8
Hmm, it could be that blobs are a bit different.

First of all, make sure all your transactions are properly committed, that goes for "read" transactions as well. If an old read-transaction isn't committed, Firebird will think it still needs access to that data, despite the fact that a new transaction will show there's only 50,000 images.

You can check your transaction counters by using "gstat" to check the database statistics. It's on the header page info.


Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle & MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com

Reply With Quote
  #8  
Old January 10th, 2007, 04:59 AM
TheMuffinMan TheMuffinMan is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 4 TheMuffinMan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 sec
Reputation Power: 0
I will check using gstat, from what i know we are definitely commiting the transaction. If there is a problem accessing the database, then the transaction will be rolled back.

I assume if there is an interrupted connection to the database that the database itself will roll back?

We either commit or rollback, we never commit-retaining. We are using Borland C++ 2006 with the ibsql components. we call the commit when done with the access.

That could explain why the database does expand. If we disconnected from the database, would that free up those old transactions?

Quote:
Originally Posted by upscene
Hmm, it could be that blobs are a bit different.

First of all, make sure all your transactions are properly committed, that goes for "read" transactions as well. If an old read-transaction isn't committed, Firebird will think it still needs access to that data, despite the fact that a new transaction will show there's only 50,000 images.

You can check your transaction counters by using "gstat" to check the database statistics. It's on the header page info.


Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle & MS SQL Server
Upscene Productions
(URL address blocked: See forum rules)
My thoughts:
(URL address blocked: See forum rules)
Database development questions? Check the forum!
(URL address blocked: See forum rules)

Reply With Quote
  #9  
Old January 10th, 2007, 05:00 AM
TheMuffinMan TheMuffinMan is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 4 TheMuffinMan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 sec
Reputation Power: 0
oh, when you mention that blobs could be a bit different, do you mean that they are handled differently in the database... ie maybe garbage collection is not working correctly?

Reply With Quote
  #10  
Old January 10th, 2007, 07:45 AM
upscene upscene is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 223 upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 7 h 14 m 50 sec
Reputation Power: 8
Quote:
I assume if there is an interrupted connection to the database that the database itself will roll back?

Yes.

Quote:
we call the commit when done with the access.

You really should commit after each database action you do. eg, select or update or whatever.

If an application has a read on data (based on transaction isolation), and the application would stay open, this would mean it doesn't allow the transaction counter to move forward.


--
Martijn Tonies
Upscene Productions

Reply With Quote
  #11  
Old January 10th, 2007, 11:55 PM
TheMuffinMan TheMuffinMan is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 4 TheMuffinMan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 sec
Reputation Power: 0
We worked the read stuff out more recently. To keep data integrity we will do a batch of command within one transaction ... a couple of selects and then a write... afterwards we will commit the transaction.

Is this bad practice which results in our error? Should we be doing each one in a separate transaction?

Does closing the connection disconnect all those other transactions that may be left open. This way would it not be better to connect and disconnect from the database after each transaction thus ensuring that each transaction is closed .. read or otherwise.

Quote:
Originally Posted by upscene
Yes.


You really should commit after each database action you do. eg, select or update or whatever.

If an application has a read on data (based on transaction isolation), and the application would stay open, this would mean it doesn't allow the transaction counter to move forward.


--
Martijn Tonies
Upscene Productions

Reply With Quote
  #12  
Old January 11th, 2007, 01:51 AM
upscene upscene is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 223 upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 7 h 14 m 50 sec
Reputation Power: 8
Sounds OK to me.

Have you checked your gstat output yet?

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > Database file size problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |