Skip to content

Estimating ivfflat balance / need to recompute index #105

Closed

Description

@olirice

Create the index after the table has some data

Waiting for data before creating the index on a vector column + periodically rebalancing been a common stumbling block for users on Supabase

What do you think about adding a "goodness of fit" estimating utility function? something like:

create function vector_index_balance_estimate(index_name name, n_samples bigint)

that

  • samples a fraction of the column's vectors
  • computes k-mean centroids for the sample
  • computes the sample's average distance to cluster centroid
  • compares the sample's average distance to same points in the index
  • returns the difference as a %

so the result could be interpreted as recomputing this index will make points approximately x% closer to their cluster centroid


That'd give users the ability to check how much drift they've experienced quickly and potentially put their index maintenance in a cron job

Activity

  1. olirice commented on Apr 26, 2023

    @olirice
    Author

    and/or possibly rebuilding the index on-insert while the number of records in the column is very small (like < 150) so users
    who create the index get a greater benefit for longer

    update: scratch that

  2. ankane commented on Apr 26, 2023

    @ankane
    Member

    Hi @olirice, thanks for sharing. For index creation, there will be a notice in the next release when the number of rows is less than the number of lists (still playing with the wording):

    NOTICE:  ivfflat index created with little data
    DETAIL:  this will cause poor recall
    HINT:  drop the index until the table has more data
    

    I'm hoping that'll take care of the biggest issue (creating the index without any data).

    (Related: I think the 2nd biggest issue is the default number of probes, which will likely increase in 0.5.0, but can't be done lightly)

    I think more index transparency, like goodness-of-fit statistics, probably makes sense in the long run, but want to hold off on the additional complexity for now.

  3. ankane commented on Apr 27, 2023

    @ankane
    Member

    Added to ideas (#27), so closing this out for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions