# Can indexes to DataFrame column be added to inprove selection performances?

**URL:** <https://discourse.julialang.org/t/can-indexes-to-dataframe-column-be-added-to-inprove-selection-performances/52456>\
**Category:** Data\
**Created:** [December 27, 2020, 2:45pm UTC](https://discourse.julialang.org/t/can-indexes-to-dataframe-column-be-added-to-inprove-selection-performances/52456 "2020-12-27T14:45:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [December 27, 2020, 2:45pm UTC](https://discourse.julialang.org/t/can-indexes-to-dataframe-column-be-added-to-inprove-selection-performances/52456/1 "2020-12-27T14:45:48Z")

</div>

In relational databases like mysql we have the option to add “indexes” to columns in order to increase selection performances (at cost of worsening them when editing the data).

Is there an option to add indexes to Julia DataFrames ? I found a [very old topic](https://github.com/JuliaData/DataFrames.jl/issues/24) about this, but not sure to what that lead (I didn’t get anything when then I did google for IndexedVectors).

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [December 27, 2020, 4:09pm UTC](https://discourse.julialang.org/t/can-indexes-to-dataframe-column-be-added-to-inprove-selection-performances/52456/2 "2020-12-27T16:09:03Z")

</div>

You can use a `GroupedDataFrame` for indexing. The lookups will be very fast, but it will only return subdataframes, even if all the indices are unique (indexing into a group will always return a one-row sub-dataframe).

This _might_ be faster than just indexing with `findfirst`, depending on your use-case. It’s worth checking.

---

<div class="post-metadata">

**Author:** ![nalimilan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nalimilan/32/147_2.png) [@nalimilan](https://discourse.julialang.org/u/nalimilan)\
**Post date:** [December 28, 2020, 1:11pm UTC](https://discourse.julialang.org/t/can-indexes-to-dataframe-column-be-added-to-inprove-selection-performances/52456/3 "2020-12-28T13:11:30Z")

</div>

You can also use [AcceleratedArrays.jl](https://github.com/andyferris/AcceleratedArrays.jl) for some columns.
