Support GIN indexes for queryables

Open
#620 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
56/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
helm, postgresql, python

Research direction

Start by inspecting the Helm values and chart definitions for queryable indexFields, then read the pypgstac issue linked as #484 and the pgSTAC settings-table approach. Done means GIN can be selected for array fields, BTREE remains the default, and the resulting database state is version-controlled and repeatable without manual SQL changes.

Written by the indexing model from the issue text.

Description

When we load "queryables" (the list of fields you're allowed to search/filter on in STAC) into pgSTAC, we use pypgstac. This tool builds a search index for each field so lookups are fast, but it only ever builds one kind of index: BTREE.

That's a problem for fields that hold lists of values (arrays), like a tags or categories field. To search those fast, Postgres needs to build a GIN index, which is built specifically for searching inside lists. There's currently no setting/flag in the pypgstac to ask for GIN instead, it always picks BTREE for you.

@bitner confirmed this in this comment: the only way to actually change the index type right now is to log into the database and manually run a SQL command to fix it. We don't want to do that, because it means the database no longer matches what's written in our Helm chart / git repo. The next person who redeploys wouldn't know that manual change ever happened.

Ideas

Keep everything defined in our Helm values (no manual database edits), but add a way to say which index type each field should get. For example:

indexFields:
  - name: "tags"
    type: "gin"
  - name: "roles"   # no type = keep using BTREE, like today

Behind the scenes, the job either needs to set the index type for each field directly in pgSTAC's own settings table, or pypgstac adds support for defining the index type (see https://github.com/stac-utils/pgstac/issues/484)

The point is, we want to automate the changes instead of doing it by hand, so it stays version-controlled and repeatable.

Dominant language
Python
Stars
34
Forks
17
Avg merge
1d 9h
Merged PRs (30d)
56

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from developmentseed/eoapi-k8s

All issues in developmentseed/eoapi-k8s

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.