Subject | Re: Delete all recs or drop & recreate table? |
---|---|
Author | Adam |
Post date | 2005-11-20T22:48:17Z |
--- In firebird-support@yahoogroups.com, Kjell Rilbe
<kjell.rilbe@a...> wrote:
leaves less garbage.
Dropping the table means that Firebird doesn't need to go through
each record, flag it as deleted, then do the garbage collection at
some time in the future when no other transaction is interested in
the old data.
Deleting all the records has the advantage of not having to worry
about 'object in use' errors, but deleted records still appear inside
indices until they are garbage collected, so if you have any
transactions that run for a long time, you may find these indices
have a lot of data. If you do choose to delete and repopulate, after
you commit the delete, run a select count(*) on the table to force
the garbage collection to happen.
objects in use by other parts of your application, this would be
quickest.
Adam
<kjell.rilbe@a...> wrote:
>or
> Hi,
>
> What is generally most efficient - to delete all records in a table
> to drop it and recreate it?I assume you mean which one is quicker, uses fewer resources and
leaves less garbage.
Dropping the table means that Firebird doesn't need to go through
each record, flag it as deleted, then do the garbage collection at
some time in the future when no other transaction is interested in
the old data.
Deleting all the records has the advantage of not having to worry
about 'object in use' errors, but deleted records still appear inside
indices until they are garbage collected, so if you have any
transactions that run for a long time, you may find these indices
have a lot of data. If you do choose to delete and repopulate, after
you commit the delete, run a select count(*) on the table to force
the garbage collection to happen.
>(1) and
> The table in question has 50-60 columns varying in size from char
> int to varchar(80). It holds about 1 million records. About 25 ofthe
> columns are indexed. Firebird 1.5.(but
>
> After being emptied, the table will be filled again with similar
> updated) data from a couple of external sources.generally
>
> I want to minimize the time it takes to empty the table. I
> drop indices, delete all records, insert new data, create indices.In this case I would say yes, providing you wont get problems with
>
> Would it be better to drop table, recreate table, insert new data,
> create indices?
objects in use by other parts of your application, this would be
quickest.
>Not if you drop the table, if you delete then it wont hurt.
> Should I do a sweep after emptying the table? Backup + restore?
>
Adam