Skip to content

@count directive makes a strange query #1880

@applyACS

Description

@applyACS

I have a attribute defined on a model like this:

type Table1 {
    agentViewedCount(pk: String @eq, agent_viewed: Boolean @eq): Int @count(relation: "rel_name")
}

this generates a query like this:

select "uuid",
(select count(*) from "rel_table" where "table1"."uuid" = "rel_table"."table1_id" and "pk" = 'key' and "agent_viewed" = 0) as "rel_name_count"
from "table1"`

Why does a select with uuid and the count? I just want the count int value.
Just the second select should be enough.

Like this it takes a loong time, it's not efficient and cant not be used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceFix or optimization of performancequestionRequest for support or clarification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions