dbTalk Databases Forums  

How does ISAM database handle deleted records?

comp.databases.mysql comp.databases.mysql


Discuss How does ISAM database handle deleted records? in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
The Natural Philosopher
 
Posts: n/a

Default How does ISAM database handle deleted records? - 05-27-2011 , 07:28 PM






Ok, as you might have guessed, I am working on something, that involves
gathering more or less real time data, every 5 minutes, and storing it
in a table.

So the table will grow...and grow...

each entry has an ID, autoindexed, and a timestamp. Plus about 10
numerical entries stored as floats.

After say - 5 years, I might want to delete data older than 5 years.


Will that release disk space? I.e. would the ISAM engine re-use disk
space of deleted rows?

And would there be any impact on speed of retrieval?

The normal search is for the latest n records...

i.e.
select * from table order by id desc limit n;

which are then processed to perform various statistics upon, and draw
graphs.

OK I have a few years in which to get it right..but its always nice to
know what to expect, in case there is something to be done to speed
things up now.

Reply With Quote
  #2  
Old   
onedbguru
 
Posts: n/a

Default Re: How does ISAM database handle deleted records? - 05-27-2011 , 08:38 PM






On May 27, 8:28*pm, The Natural Philosopher <t... (AT) invalid (DOT) invalid>
wrote:
Quote:
Ok, as you might have guessed, I am working on something, that involves
gathering more or less real time data, every 5 minutes, and storing it
in a table.

So the table will grow...and grow...

each entry has an ID, autoindexed, and a timestamp. Plus about 10
numerical entries stored as floats.

After say - 5 years, I might want to delete data older than 5 years.

Will that release disk space? I.e. would the ISAM engine re-use disk
space of deleted rows?

And would there be any impact on speed of retrieval?

The normal search is for the latest n records...

i.e.
select * from table order by id desc limit n;

which are then processed to perform *various statistics upon, and draw
graphs.

OK I have a few years in which to get it right..but its always nice to
know what to expect, in case there is something to be done to speed
things up now.

1) use Partitioning.
http://dev.mysql.com/doc/refman/5.1/...ning-list.html

2) Use the DATA DIRECTORY and INDEX DIRECTORY directives
Example:
(PARTITION p4c VALUES LESS THAN (201112) DATA DIRECTORY = '/opt/data/'
INDEX DIRECTORY =
'/opt/index/' ENGINE = MYISAM,
PARTITION p51 VALUES LESS THAN (201201) DATA DIRECTORY = '/opt/data/'
INDEX DIRECTORY =
'/opt/index/' ENGINE = MYISAM,
....
3) Then when it is time, use ALTER TABLE TRUNCATE PARTITION then ALTER
TABLE DROP PARTITION. This "should" delete the data files associated
with those partitions.

As always, not all solutions fit every scenario - YMMV.
To ensure it works the way you think that it works, TEST, TEST, TEST
and TEST again.

Reply With Quote
  #3  
Old   
Luuk
 
Posts: n/a

Default Re: How does ISAM database handle deleted records? - 05-28-2011 , 04:31 AM



On 28-05-2011 02:28, The Natural Philosopher wrote:
Quote:
Ok, as you might have guessed, I am working on something, that involves
gathering more or less real time data, every 5 minutes, and storing it
in a table.

So the table will grow...and grow...

each entry has an ID, autoindexed, and a timestamp. Plus about 10
numerical entries stored as floats.

After say - 5 years, I might want to delete data older than 5 years.


Will that release disk space? I.e. would the ISAM engine re-use disk
space of deleted rows?

And would there be any impact on speed of retrieval?

The normal search is for the latest n records...

i.e.
select * from table order by id desc limit n;

which are then processed to perform various statistics upon, and draw
graphs.

OK I have a few years in which to get it right..but its always nice to
know what to expect, in case there is something to be done to speed
things up now.
http://dev.mysql.com/doc/refman/5.5/...ize-table.html
OPTIMIZE TABLE should be used if you have deleted a large part of a
table or if you have made many changes to a table with variable-length
rows (tables that have VARCHAR, VARBINARY, BLOB, or TEXT columns).
Deleted rows are maintained in a linked list and subsequent INSERT
operations reuse old row positions. You can use OPTIMIZE TABLE to
reclaim the unused space and to defragment the data file. After
extensive changes to a table, this statement may also improve
performance of statements that use the table, sometimes significantly.


--
Luuk

Reply With Quote
  #4  
Old   
Luuk
 
Posts: n/a

Default Re: How does ISAM database handle deleted records? - 05-28-2011 , 04:32 AM



On 28-05-2011 03:38, onedbguru wrote:
Quote:
To ensure it works the way you think that it works
you forgot to say he should test it.....



--
Luuk

Reply With Quote
  #5  
Old   
Axel Schwenke
 
Posts: n/a

Default Re: How does ISAM database handle deleted records? - 05-28-2011 , 10:51 AM



The Natural Philosopher <tnp (AT) invalid (DOT) invalid> wrote:

Quote:
Ok, as you might have guessed, I am working on something, that involves
gathering more or less real time data, every 5 minutes, and storing it
in a table.
Do yourself a favor and have a look at rrdtool.
This is nearly perfect for time series data.

If you really need to put your data into a RDBMs,
then go for InnoDB, not MyISAM. The PK should be
(timestamp, datasource). Then the clustering on
the PK will automagically give fast access for
time-range queries and low fragmentation when
deleting historical data.


XL

Reply With Quote
  #6  
Old   
The Natural Philosopher
 
Posts: n/a

Default Re: How does ISAM database handle deleted records? - 05-28-2011 , 10:58 AM



Axel Schwenke wrote:
Quote:
The Natural Philosopher <tnp (AT) invalid (DOT) invalid> wrote:

Ok, as you might have guessed, I am working on something, that involves
gathering more or less real time data, every 5 minutes, and storing it
in a table.

Do yourself a favor and have a look at rrdtool.
This is nearly perfect for time series data.

If you really need to put your data into a RDBMs,
then go for InnoDB, not MyISAM. The PK should be
(timestamp, datasource). Then the clustering on
the PK will automagically give fast access for
time-range queries and low fragmentation when
deleting historical data.


All TOO professional. This is a zero budget bit of research.

But thanks for the advice.

PK is on those fields anyway.

Retrieval is almost non time critical. I can stand a minute if I ever
need to grab a huge chunk.

Gathering the data is the most important thing, and that's up and
running..if I need to port to another dB later, well that's not a
problem either.


> XL

Reply With Quote
  #7  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: How does ISAM database handle deleted records? - 05-28-2011 , 01:09 PM



On 5/28/2011 11:58 AM, The Natural Philosopher wrote:
Quote:
Axel Schwenke wrote:
The Natural Philosopher <tnp (AT) invalid (DOT) invalid> wrote:

Ok, as you might have guessed, I am working on something, that involves
gathering more or less real time data, every 5 minutes, and storing it
in a table.

Do yourself a favor and have a look at rrdtool.
This is nearly perfect for time series data.

If you really need to put your data into a RDBMs,
then go for InnoDB, not MyISAM. The PK should be
(timestamp, datasource). Then the clustering on
the PK will automagically give fast access for
time-range queries and low fragmentation when
deleting historical data.


All TOO professional. This is a zero budget bit of research.

No more or less professional than using MyISAM. And anyone with half an
inkling wouldn't have to spend much (if any) time "researching". A
quick read of the manual would suffice.

But your comments aren't surprising, considering the source.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
Reply




Thread Tools
Display Modes

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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.