Skip to content

Conversation

@sheetalshah1007
Copy link
Contributor

@sheetalshah1007 sheetalshah1007 commented Jan 30, 2026

What changes were proposed in this pull request?

Introduces searchRelatedEntitiesV2 with graph-layer pagination support, achieving a significant performance improvement for large datasets and deep pagination scenarios (offset > 1000). The new method selects between database-level pagination (for unsorted queries) and traditional Gremlin traversal (for sorted queries), while maintaining full backward compatibility with the existing searchRelatedEntities method

Why It Was Needed?

The earlier searchRelatedEntities implementation applies default sorting by the name attribute in ascending order when no sort criteria are provided. This requires loading all related entities into memory before sorting and pagination can be applied. As a result, queries involving a large number of relationships or high offset values suffer from significant performance degradation, leading to long response times and, in some cases, timeouts.

How was this patch tested?

Performance validation was conducted on test databases with 100, 1K, 10K, and 50K entities(relationships), measuring server-side execution time from audit logs across multiple manual test scenarios.

Performance Impact (Accurate Data)

Scenario Dataset Offset Original V2 Speedup
Medium 10K 5,000 681 ms 55 ms 12.4x
Deep 50K 25,000 3,185 ms 136 ms 23.4x ✅
Extreme 50K 100,000 3,371 ms 122 ms 27.6x

• No regression for sorted queries

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.

2 participants