mini\Table\Wrappers\OptimizingTable
class
Documentation
Adaptive optimization wrapper that measures and improves table access patterns
Wraps any table and transparently optimizes repeated operations:
- Builds TreapIndex for frequently accessed columns
- Escalates to SQLite (InMemoryTable) for large datasets
- Measures actual performance to make decisions
Use hints when caller knows access patterns upfront:
$optimized = OptimizingTable::from($table)
->withExpectedHasCalls(10000)
->withIndexOn('user_id', 'order_id');
Inheritance
Extends: mini\Table\Wrappers\AbstractTableWrapper
Implements:
mini\Table\Contracts\TableInterface
Traversable
Countable
IteratorAggregate
mini\Table\Contracts\SetInterface
Constants (4)
| Name | Value |
|---|---|
MEASURE_CALLS |
3 |
INDEX_BENEFIT_THRESHOLD_MS |
50.0 |
SQLITE_ROW_THRESHOLD |
500000 |
SQLITE_TIME_THRESHOLD |
2.0 |
Properties (17)
int $expectedHasCalls
int $expectedEqCalls
array $indexColumns
int $hasCallCount
float $hasTotalTime
array $eqCallCounts
array $eqTotalTimes
array $columnIndexes
string $hasStrategy
array $eqStrategies
array $rowCache
Closure $compareFn
int $limit
int $offset
Methods (52)
Wrap a table for optimization, or return if already wrapped
Hint: expected number of has() calls
Hint: expected number of eq() calls
Hint: columns that will be used for eq() lookups
Documentation missing
Documentation missing
Documentation missing
Documentation missing
Documentation missing
Documentation missing
Documentation missing
Documentation missing
Documentation missing
Documentation missing
Documentation missing
Documentation missing
Get all rows, caching for reuse during index building
Documentation missing
Documentation missing
Documentation missing
Documentation missing
Get current optimization state for debugging
public
__construct()
inherited from mini\Table\Wrappers\AbstractTableWrapper
Documentation missing
public
getSource()
inherited from mini\Table\Wrappers\AbstractTableWrapper
Get the source table this wrapper delegates to
public
getProperty()
inherited from mini\Table\Wrappers\AbstractTableWrapper
Documentation missing
public
hasProperty()
inherited from mini\Table\Wrappers\AbstractTableWrapper
Documentation missing
protected
materialize()
inherited from mini\Table\Wrappers\AbstractTableWrapper
Documentation missing
public
getColumns()
inherited from mini\Table\Wrappers\AbstractTableWrapper
Documentation missing
public
getAllColumns()
inherited from mini\Table\Wrappers\AbstractTableWrapper
Documentation missing
public
columns()
inherited from mini\Table\Wrappers\AbstractTableWrapper
Documentation missing
public
count()
inherited from mini\Table\Wrappers\AbstractTableWrapper
Documentation missing
public
load()
inherited from mini\Table\Wrappers\AbstractTableWrapper
Documentation missing
protected
getCompareFn()
inherited from mini\Table\Wrappers\AbstractTableWrapper
Documentation missing
public
in()
inherited from mini\Table\Wrappers\AbstractTableWrapper
Documentation missing
public
like()
inherited from mini\Table\Wrappers\AbstractTableWrapper
Documentation missing
public
order()
inherited from mini\Table\Wrappers\AbstractTableWrapper
Documentation missing
public
or()
inherited from mini\Table\Wrappers\AbstractTableWrapper
Documentation missing
public
limit()
inherited from mini\Table\Wrappers\AbstractTableWrapper
Documentation missing
public
__clone()
inherited from mini\Table\AbstractTable
Hook for subclasses to customize clone behavior
public
getRowKeyColumns()
inherited from mini\Table\AbstractTable
Get column name(s) that the row key represents
public
offset()
inherited from mini\Table\AbstractTable
Documentation missing
public
getLimit()
inherited from mini\Table\AbstractTable
Documentation missing
public
getOffset()
inherited from mini\Table\AbstractTable
Documentation missing
public
withAlias()
inherited from mini\Table\AbstractTable
Documentation missing
public
getTableAlias()
inherited from mini\Table\AbstractTable
Get the current table alias (null if not set)
public
union()
inherited from mini\Table\AbstractTable
Documentation missing
public
except()
inherited from mini\Table\AbstractTable
Documentation missing
public
distinct()
inherited from mini\Table\AbstractTable
Documentation missing
public
exists()
inherited from mini\Table\AbstractTable
Documentation missing
protected
getPrimaryKeyColumn()
inherited from mini\Table\AbstractTable
Get the primary key column definition (cached)
public
final
getIterator()
inherited from mini\Table\AbstractTable
Iterate over rows with visible columns only
public
withProperty()
inherited from mini\Table\AbstractTable
Return table with property set