Create an index on one or more columns in an Andromeda table

createIndex(tbl, columnNames, unique = FALSE, indexName = NULL)

Arguments

tbl

An Andromeda table (or any other 'DBI' table).

columnNames

A vector of column names (character) on which the index is to be created.

unique

Should values in the column(s) be enforced to be unique?

indexName

The name of the index. If not provided, a random name will be generated.

Value

Invisibly returns the input table.

Details

Indices can speed up subsequent queries that use the indexed columns, but can take time to create, and will take additional space on the drive.

Examples

andr <- andromeda(cars = cars)

createIndex(andr$cars, "speed")

# Will be faster now that speed is indexed:
andr$cars %>%
  filter(speed == 10) %>%
  collect()
#> # A tibble: 3 × 2
#>   speed  dist
#>   <dbl> <dbl>
#> 1    10    18
#> 2    10    26
#> 3    10    34

close(andr)