Skip to content

ShardingJDBC 5.5.0 with Spring Boot 3.3.13: In-Memory Merge Query Not Triggering for Pagination (Returns 20 Instead of 5 Records) #37125

@jiananxu

Description

@jiananxu

Environment

  • Spring Boot Version: 3.3.13
  • ShardingJDBC Version: 5.5.0
  • Database: Dameng Database (Oracle-like syntax)
  • Sharding Configuration: 4 tables with pagination rules

Problem Description

When executing pagination queries using Spring Data's PageRequest, the expected in-memory merge query does not trigger, resulting in incorrect pagination behavior.

Code Example:

PageRequest page = PageRequest.of(0, 5, Sort.by(Sort.Direction.DESC, "id"));
Page<BusinessLog> certs = businessLogDao.findAll(page);

Expected Result:

  • Should return 5 records (as specified in page size)
  • Results should be merged from all 4 sharded tables and sorted by ID in descending order

Actual Result:

  • Returns 20 records (5 from each of the 4 shards, without proper merging)
  • No in-memory merge operation appears to be executed

Key Symptoms

  1. Pagination size is ignored - returns 20 records instead of 5
  2. Sorting may not be properly applied across all shards
  3. No evidence of in-memory result merging

Questions & Assistance Needed

1. Configuration Issues

  • Are there specific configurations required to enable in-memory merging for pagination in ShardingJDBC 5.5.0?
  • Could there be compatibility issues with Dameng database?

2. Manual Triggering

  • Is there a way to manually trigger or force in-memory merge queries?
  • Are there specific APIs or configurations to enforce result merging?

3. Troubleshooting Guidance

  • What would be the recommended approach to debug this issue?
  • Are there known limitations with Spring Data JPA repository methods and ShardingJDBC pagination?

4. Database Specifics

  • Could the Dameng database (Oracle-like) require special handling?
  • Are there dialect configurations or compatibility settings needed?

Thank you for your assistance!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions