Skip to content

enhance sub-issue query performance with optimized annotations and subqueries (2.6s -> 0.07s)#8889

Merged
sriramveeraghanta merged 1 commit intomakeplane:previewfrom
PhuongPN6689:feature/optimize-sub-issue-query
Apr 14, 2026
Merged

enhance sub-issue query performance with optimized annotations and subqueries (2.6s -> 0.07s)#8889
sriramveeraghanta merged 1 commit intomakeplane:previewfrom
PhuongPN6689:feature/optimize-sub-issue-query

Conversation

@PhuongPN6689
Copy link
Copy Markdown
Contributor

@PhuongPN6689 PhuongPN6689 commented Apr 13, 2026

…bqueries

Description

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Screenshots and Media (if applicable)

Test Scenarios

References

Summary by CodeRabbit

  • Refactor
    • Optimized internal sub-issue query handling and data aggregation patterns for improved performance.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 13, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 13, 2026

📝 Walkthrough

Walkthrough

Reworked the sub-issue endpoint's queryset annotations to use correlated Subquery expressions with Count and Coalesce functions, replacing join-based patterns. Label, assignee, and module aggregations were refactored to use Subquery-based ArrayAgg over dedicated models. Query results are now converted to dictionary values immediately, with grouping via dictionary key indexing instead of model attributes. Explicit order-by clause was removed.

Changes

Cohort / File(s) Summary
Sub-issue Queryset Optimization
apps/api/plane/app/views/issue/sub_issue.py
Refactored annotations from join-based patterns to correlated Subquery expressions with Count/Coalesce for link, attachment, and sub-issue counts. Replaced join-based ArrayAgg with Subquery-based ArrayAgg over dedicated models for labels, assignees, and modules. Converted result handling from model instances to dictionary values with dictionary key indexing for grouping logic. Removed explicit .order_by("-created_at").

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Subqueries dance where joins once stood,
Dictionary keys now group as they should,
Count and Coalesce in harmony blend,
Aggregations refined from start to end!
✨ Refactored queries—so swift, so sweet!

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete: the Description section is empty, no screenshots/test scenarios are provided, no related issues are referenced, and the Type of Change selection (bug fix) appears misclassified given the changeset's focus on performance optimization rather than bug fixing. Add a detailed description of the query optimization changes, select 'Performance improvements' as the primary change type, provide test scenarios documenting performance impact, and include any related issue references.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and specifically describes the main change: optimizing sub-issue query performance through improved annotations and subqueries, with concrete performance metrics (2.6s -> 0.07s).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@PhuongPN6689 PhuongPN6689 changed the title enhance sub-issue query performance with optimized annotations and subqueries enhance sub-issue query performance with optimized annotations and subqueries (2.6s -> 0.07s) Apr 13, 2026
@sriramveeraghanta
Copy link
Copy Markdown
Member

@PhuongPN6689 Changes looks good to us. Please sign the CLA. We will merge these changes.

@sriramveeraghanta sriramveeraghanta merged commit 13db2f8 into makeplane:preview Apr 14, 2026
11 checks passed
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.

4 participants