Create and use Bitmap Indexes
mainFor frequently used queries, you can create an index using CreateIndex(). An index is defined by a column name and a predicate function. Once created, you can query the index using With(indexName), which is significantly faster (often 10-100x) because it uses bitmap indexing and logical operations instead of full scans.
Index Operations:
Union(otherIndex): Performs a logicalOR(merges results).Without(otherIndex): Performs a logicalAND NOT(difference).With(index): Selects rows matching the index.
// Create the index "rogue" in advance
out.CreateIndex("rogue", "class", func(v interface{}) bool {
return v == "rogue"
})
// This returns the same result as the query before, but much faster
players.Query(func(txn *column.Txn) error {
count := txn.With("rogue").Count()
return nil
})