org.apache.derby.iapi.store.access
Interface RowCountable

All Known Subinterfaces:
GenericScanController, GroupFetchScanController, ScanController, ScanControllerRowSource, ScanManager, StoreCostController
All Known Implementing Classes:
BTreeCostController, BTreeScan, GenericCostController, GenericScanController, HeapCostController, HeapScan, MergeScanRowSource, Scan, SortBufferRowSource

public interface RowCountable

RowCountable provides the interfaces to read and write row counts in tables.

See Also:
ScanController, StoreCostController

Method Summary
 long getEstimatedRowCount()
          Get the total estimated number of rows in the container.
 void setEstimatedRowCount(long count)
          Set the total estimated number of rows in the container.
 

Method Detail

getEstimatedRowCount

public long getEstimatedRowCount()
                          throws StandardException
Get the total estimated number of rows in the container.

The number is a rough estimate and may be grossly off. In general the server will cache the row count and then occasionally write the count unlogged to a backing store. If the system happens to shutdown before the store gets a chance to update the row count it may wander from reality.

For btree conglomerates this call will return the count of both user rows and internal implementaation rows. The "BTREE" implementation generates 1 internal implementation row for each page in the btree, and it generates 1 internal implementation row for each branch row. For this reason it is recommended that clients if possible use the count of rows in the heap table to estimate the number of rows in the index rather than use the index estimated row count.

Returns:
The total estimated number of rows in the conglomerate.
Throws:
StandardException - Standard exception policy.

setEstimatedRowCount

public void setEstimatedRowCount(long count)
                          throws StandardException
Set the total estimated number of rows in the container.

Often, after a scan, the client of RawStore has a much better estimate of the number of rows in the container than what store has. For instance if we implement some sort of update statistics command, or just after a create index a complete scan will have been done of the table. In this case this interface allows the client to set the estimated row count for the container, and store will use that number for all future references.

This routine can also be used to set the estimated row count in the index to the number of rows in the base table, another workaround for the problem that index estimated row count includes non-user rows.

Parameters:
count - the estimated number of rows in the container.
Returns:
The total estimated number of rows in the conglomerate.
Throws:
StandardException - Standard exception policy.

Built on Mon 2007-06-04 09:58:47+0400, from revision ???

Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.