Hi Dillon. Since you’re self-hosting Postgres, you can create a partial expression index per key as a stopgap — e.g. for user.id We can add this index on Phoenix on the next major version release.
CREATE INDEX CONCURRENTLY ix_spans_attributes_user_id
ON public.spans ((((attributes #>> '{user,id}'::text[]))::varchar))
WHERE (((attributes #>> '{user,id}'::text[]))::varchar) IS NOT NULL;And the same pattern works for any metadata key you filter on. metadata is intentionally a free-form blob, so Phoenix can’t index it generically, but you probably know which keys matter to your system. E.g. if you filter on metadata["conversation_id"]:
CREATE INDEX CONCURRENTLY ix_spans_attributes_metadata_conversation_id
ON public.spans ((((attributes #>> '{metadata,conversation_id}'::text[]))::varchar))
WHERE (((attributes #>> '{metadata,conversation_id}'::text[]))::varchar) IS NOT NULL;