luckyframework / luckyframework/avram

Support for CURSOR

Open
#1,008 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request hacktoberfest
Dominant language
Crystal
Stars
183
Forks
67
PR merge metrics
No merged PRs in 30d

Description

A `CURSOR` would allow us to paginate really large collections.

I've never implemented or even really used these directly, but I found this example

```sql
-- We must be in a transaction
BEGIN;
-- Open a cursor for a query
DECLARE medley_cur CURSOR FOR SELECT * FROM medley;
-- Retrieve ten rows
FETCH 10 FROM medley_cur;
-- ...
-- Retrieve ten more from where we left off
FETCH 10 FROM medley_cur;
-- All done
COMMIT;
```

I honestly have no clue how this will work, but I think we would probably want some alternate method of iterating that appends the cursor to the query?

```crystal
UserQuery.new.each_with_cursor(fetch: 10) do |user|
#??
end

UserQuery.new.cursor_fetch(10).each do |user|

end
```

If anyone has any ideas around this, I'm open.

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

The issue names no implementation files, tests, or entry points. Start by reviewing Avram's existing query iteration API and the PostgreSQL cursor requirements, then establish the API and transaction behavior for cursor pagination. Done means large collections can be paginated through a tested cursor workflow.

Written by the indexing model from the issue text.

Assessment

Tech stack
crystal, postgresql
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.