ozontech / ozontech/seq-db

Incorrect "total" value in search in nested index

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

Nobody has claimed this yet.

bug
Dominant language
Go
Stars
131
Forks
16
Avg merge
2d 4h
Merged PRs (30d)
11

Description

We have deduplication for list of IDS

if total == 0 || lastID != id { // lids increase monotonically, it's enough to compare current id with the last one
	ids = append(ids, seq.IDSource{ID: id})
}
lastID = id

But we didn't have it for total calculation. To use deduplication logic, we need to convert LID to seq.ID, this requires reading MIDs and RIDs blocks from disk, which slows down the query.

An additional problem is that in the context of performing a search, we have no information that a nested index is involved in the search, and we cannot decide to take the more expensive branch for the "total".

See iterateEvalTree() function in frac/processor/search.go

Contributor guide

Open the contributing guide

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.

Research direction

Start with iterateEvalTree() in frac/processor/search.go and trace how total is calculated versus the existing deduplication of IDs. Done means nested-index searches report a deduplicated total while accounting for the additional disk reads required to convert LIDs to seq.IDs.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
databases, search
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.