Skip to content

Add indexed, timestamped, cursor-paginated instance listing APIs#182

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/enabling-efficient-paginated-listing
Draft

Add indexed, timestamped, cursor-paginated instance listing APIs#182
Copilot wants to merge 2 commits into
mainfrom
copilot/enabling-efficient-paginated-listing

Conversation

Copy link
Copy Markdown

Copilot AI commented May 27, 2026

df.instances listing was expensive for external clients because chronological reads had no supporting index, df.list_instances had no server-side pagination, and timestamps were omitted from the response. This made efficient page-by-page UI listing and metadata display harder than necessary.

  • Schema/index changes

    • Added a chronological index for stable keyset scans:
      • idx_instances_created_at_desc_id on (created_at DESC, id).
  • df.list_instances contract update

    • Extended return shape to include:
      • created_at
      • completed_at
    • Switched ordering to ORDER BY created_at DESC, id DESC for deterministic chronological output.
    • Replaced silent limit_count truncation with explicit bound validation.
  • New paginated API

    • Added df.list_instances_paginated(status_filter, limit_count, after_cursor).
    • Uses keyset pagination on (created_at, id) with limit + 1 lookahead.
    • Returns:
      • instance fields + timestamps
      • total_count
      • next_cursor (or NULL when exhausted)
    • Supports optional status_filter under existing RLS behavior.
  • Privilege/documentation updates

    • Added df.list_instances_paginated(text, integer, text) to df.grant_usage(...) function grants.
    • Updated user guide and changelog for new/expanded monitoring surfaces.
-- First page
SELECT * FROM df.list_instances_paginated(NULL, 20, NULL);

-- Next page
SELECT * FROM df.list_instances_paginated(
  NULL,
  20,
  '2026-01-01 12:00:00+00:00|a1b2c3d4'
);

Co-authored-by: pinodeca <32303022+pinodeca@users.noreply.github.com>
Copilot AI changed the title [WIP] Update df.instances to support efficient pagination for external clients Add indexed, timestamped, cursor-paginated instance listing APIs May 27, 2026
Copilot AI requested a review from pinodeca May 27, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enabling efficient paginated listing of df.instances for external clients

2 participants