{"id":21090256,"url":"https://github.com/jun-labs/async-paging","last_synced_at":"2025-08-20T17:23:48.180Z","repository":{"id":243819964,"uuid":"791139208","full_name":"jun-labs/async-paging","owner":"jun-labs","description":"📗 비동기 페이징 예제 코드.","archived":false,"fork":false,"pushed_at":"2024-06-11T12:51:30.000Z","size":71,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-01-21T01:11:29.429Z","etag":null,"topics":["async","cursor","limit","offset","page","pagination","paging","sync"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jun-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-24T07:01:03.000Z","updated_at":"2024-06-11T12:51:33.000Z","dependencies_parsed_at":"2024-06-11T10:59:54.607Z","dependency_job_id":"75e8e44c-ffd9-4775-8988-5f3a5f733e8a","html_url":"https://github.com/jun-labs/async-paging","commit_stats":null,"previous_names":["jun-labs/paging"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jun-labs%2Fasync-paging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jun-labs%2Fasync-paging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jun-labs%2Fasync-paging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jun-labs%2Fasync-paging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jun-labs","download_url":"https://codeload.github.com/jun-labs/async-paging/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243532557,"owners_count":20306157,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","cursor","limit","offset","page","pagination","paging","sync"],"created_at":"2024-11-19T21:35:02.275Z","updated_at":"2025-03-14T06:15:08.519Z","avatar_url":"https://github.com/jun-labs.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Async Paging\n\n페이징 **`카운트`**, **`데이터 페치`** 쿼리 분리 예제. \n\n\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e\n\n## 💻 프로그램 실행\n\n빌드 후, 프로젝트 실행 합니다. 애플리케이션 실행 후, 데이터 초기화 작업이 있기 때문에 잠깐 대기합니다. \n\n```shell\n./gradlew build\n```\n\n```shell\njava -jar build/libs/paging-async-0.0.1.jar\n```\n\n\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e\n\n## 📚 Content\n\n페이징에서 **`카운트`** 와 **`데이터 페칭`** 두 쿼리가 순차적으로 실행됩니다. 이를 분리한 후, 비동기로 조회하면 조회 성능을 조금 더 향상시킬 수 있습니다. \n\n```kotlin\n@Repository\nclass UserEntityReadRepository(\n    private val queryFactory: JPAQueryFactory,\n) : UserReadRepository {\n\n    companion object {\n        private val totalCountExpression = numberTemplate(Long::class.java, \"count(1)\")\n    }\n\n    override suspend fun findUsers(\n        page: Int,\n        size: Int,\n    ): Pair\u003cLong, List\u003cUser\u003e\u003e = coroutineScope {\n        val totalCount = async {\n            queryFactory.select(totalCountExpression)\n                .from(user)\n                .fetchOne() ?: 0L\n        }\n\n        val findUsers = async {\n            queryFactory.selectFrom(user)\n                .offset((page) * size.toLong())\n                .limit(10)\n                .fetch()\n        }\n        Pair(totalCount.await(), findUsers.await())\n    }\n}\n```\n\n\u003e 단, 이는 offset 방식의 한계는 벗어나지 못하므로, 데이터가 많을 수록 속도가 느려집니다. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjun-labs%2Fasync-paging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjun-labs%2Fasync-paging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjun-labs%2Fasync-paging/lists"}