locked
Total deleted counts file byte location on VFP header structure ? RRS feed

  • Question

  • Hi all, does anyone knows where exactly does total numbers of deleted records store on headers ? file byte range in particular.

    Sunday, March 17, 2013 7:55 AM

Answers

  • Using a FileViewer and VFP Help, I cannot see that the number of deleted records is held in the header.

    The total number of records held in the table, which includes deleted records, is held in the header at byte positions 4-7.

    At the start of each record is a flag to show if the record is deleted or not.

    Look under Table File Structure in Help to see the rest of the positions and usage within the header record.

    • Proposed as answer by Pavel Celba Sunday, March 17, 2013 7:14 PM
    • Marked as answer by Nhylz Monday, March 18, 2013 1:17 PM
    Sunday, March 17, 2013 11:28 AM
    Answerer
  • Computers have a lot of memory today... VFP keeps the table in memory buffers whenever possible thus reading is very fast namely when you open the table exclusively. And what was the record size in your case?

    To measure more realistic time you would need to restart VFP before the COUNT. You may also create an index:

    INDEX ON DELETED() TAG deleted BINARY

    which will then give optimized speed.

    • Marked as answer by Nhylz Monday, March 18, 2013 1:17 PM
    Monday, March 18, 2013 8:39 AM

All replies

  • Using a FileViewer and VFP Help, I cannot see that the number of deleted records is held in the header.

    The total number of records held in the table, which includes deleted records, is held in the header at byte positions 4-7.

    At the start of each record is a flag to show if the record is deleted or not.

    Look under Table File Structure in Help to see the rest of the positions and usage within the header record.

    • Proposed as answer by Pavel Celba Sunday, March 17, 2013 7:14 PM
    • Marked as answer by Nhylz Monday, March 18, 2013 1:17 PM
    Sunday, March 17, 2013 11:28 AM
    Answerer

  • Hi EnglishBo2,

    Yes 4-7 header offset bytes stores the total numbers of records in the table, ^_^y I'm just too lazy  to do some byte per byte investigation if deleted count are store in the header somewhere from the reserved header offsets like 12-26, 29-32, Etc..

    I am just wondering if I issued the command COUNT FOR DELETED() with 1 million records VFP responded  immediately even if I deleted the last record.

    Maybe VFP is just really fast in reading the file in sequential operation counting each record first byte offset with a value of 42. Record block offset first byte with a value of  42 mark as deleted and 32 for non deleted records.
    Sunday, March 17, 2013 12:15 PM
  • VFP uses index for the command speed optimization whenever available. To obtain unoptimized time you may delete the index or issue:

    COUNT FOR DELETED() NOOPTIMIZE

    Sunday, March 17, 2013 7:20 PM
  • Hi Pavel Celba,

    I created the table without an index and append 1 Million records, issuing a command COUNT FOR DELETE() to mDelCnt has an immediate result.

    I want some idea how Visual Foxpro count the deleted records iternally because it count fast even w/o an index ^_^y...

    Monday, March 18, 2013 1:23 AM
  • Cont...

    Because VFP counted it really fast, it gives me a thought maybe upon DELETING a records, VFP stored the total deleted counts to header and just retrived it when COUNT FOR DELETED() is issue, but upon investigation that is not the case it really does not store total deleted counts in the header.

    Monday, March 18, 2013 1:29 AM
  • Computers have a lot of memory today... VFP keeps the table in memory buffers whenever possible thus reading is very fast namely when you open the table exclusively. And what was the record size in your case?

    To measure more realistic time you would need to restart VFP before the COUNT. You may also create an index:

    INDEX ON DELETED() TAG deleted BINARY

    which will then give optimized speed.

    • Marked as answer by Nhylz Monday, March 18, 2013 1:17 PM
    Monday, March 18, 2013 8:39 AM
  • That's it!  VFP by default fetch 100 records at time.

    Monday, March 18, 2013 1:17 PM