Skip to content

Audit for database queries that use firstOrNull instead of a limit #545

Description

@nullpointer0x00

Summary

Audit the codebase for database queries returning large datasets and using firstOrNull on the Kotlin side, which can be optimized by adding limit(1) directly in the database query.

Problem Definition

Some queries were fetching and serializing large datasets, up to 316k records, only to use the first result with firstOrNull. This caused longer query times, unnecessary network data transfer, and serialization overhead. See PR #544 for a related example.

Proposal

Perform an audit to identify and update such queries to include limit(1) where appropriate.


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions