Skip to content

Partial Results in Paginated Search Invokes Repetitive Search #1403

Open

Description

@MikeShi42

[Needs Validation]

For a given search over a windowed time range (ex. over several days) and if there are only a few results in a given window (ex. 3 rows), we dispatch an extra extraneous SELECT .. LIMIT 200 OFFSET 3 query, even though we know if the last result length is less than limit, we can move onto the next window.

This can increase pagination latency.

We probably need to improve the conditional check here to compare the last page result count with the LIMIT we requested before going to the next offset: https://github.com/hyperdxio/hyperdx/blob/a9f10c5ff97c20b67491293ccd823901ffb11a23/packages/app/src/hooks/useOffsetPaginatedQuery.tsx#L104

Activity

  1. MikeShi42 commented on Nov 21, 2025

    @MikeShi42
    ContributorAuthor

    @claude please help fix this conditional error

  2. claude commented on Nov 21, 2025

    @claude

    Claude finished @MikeShi42's task —— View job • claude/issue-1403-20251121-2332 • Create PR ➔


    Fixed pagination conditional error ✅

    Tasks

    • Read and analyze the pagination hook file
    • Identify the conditional logic issue
    • Implement fix to prevent extraneous queries
    • Commit and push changes
    • Provide PR creation link

    Analysis

    Found the issue in packages/app/src/hooks/useOffsetPaginatedQuery.tsx:104. The current code checks:

    if (lastPage.data.length > 0)

    But this doesn't account for partial results. If we request 200 rows and only get 3, we know there are no more results in this window, yet the code will still dispatch another query with OFFSET 3.

    Fix Applied

    Updated the condition to:

    const requestedLimit = config.limit?.limit ?? 200;
    if (lastPage.data.length > 0 && lastPage.data.length >= requestedLimit)

    Now the pagination will only continue if we received a full page of results, indicating there might be more data. If we get fewer results than requested, we skip the extraneous query and move to the next time window.

    This should reduce pagination latency by eliminating unnecessary queries when we already know there are no more results in the current window.

    Next Steps

    Important: Please run the linting commands before merging:

    cd packages/app && yarn run lint:fix
    yarn run lint

    The fix has been pushed to branch claude/issue-1403-20251121-2332.


    Branch |

  3. added a commit that references this issue on Nov 21, 2025
    6e3d279
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions