Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not generate unnecessary db queries #969

Closed
do4gr opened this issue Jul 29, 2020 · 0 comments · Fixed by #1043
Closed

Do not generate unnecessary db queries #969

do4gr opened this issue Jul 29, 2020 · 0 comments · Fixed by #1043
Assignees
Labels
kind/improvement An improvement to existing feature and code. tech/engines/query engine Issue in the Query Engine tech/engines Issue for tech Engines.
Milestone

Comments

@do4gr
Copy link
Member

do4gr commented Jul 29, 2020

I stumbled over cases where we do requests for related nodes even though we did not find a parent node.

      s"""
         |model User {
         |  id       Int     @id
         |  name     String?
         |  postId   Int?
         |  post2Id  Int?
         |  post     Post?   @relation( fields: [postId], references: [id])
         |  post2    Post2?  @relation( fields: [post2Id], references: [id])
         |}
         |
         |model Post {
         |  id       Int     @id
         |  name     String?
         |  user     User?
         |}         
         |
         |model Post2 {
         |  id       Int     @id
         |  name     String?
         |  user     User?
         |}         
         |
         |
       """.stripMargin
    }
    database.setup(project)

    val find_1 = server.query(
      """
        |query {
        |  users(where: {id: 5 }){
        |    id
        |    name
        |    post  {name}
        |    post2 {name}
        |  }
        |}
      """,
      project
    )

    find_1.toString should be("{\"data\":{\"users\":[]}}")

Since I created no nodes, only the top level should be queried from the db. But the following SQL statements are sent:

Screen Shot 2020-07-29 at 15 20 55

The last two are unnecessary. Hint from @dom the place to catch that would be in nested read if joined_projections are empty.

@do4gr do4gr self-assigned this Jul 29, 2020
@mavilein mavilein assigned do4gr and unassigned do4gr Jul 29, 2020
@mavilein mavilein added the tech/engines Issue for tech Engines. label Aug 5, 2020
@janpio janpio added the kind/improvement An improvement to existing feature and code. label Aug 5, 2020
@janpio janpio added this to the Backlog 2.5.0 milestone Aug 5, 2020
@janpio janpio modified the milestones: Backlog 2.5.0, Backlog 2.6.0 Aug 18, 2020
@do4gr do4gr modified the milestones: Backlog 2.6.0, Release 2.6.0 Aug 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/improvement An improvement to existing feature and code. tech/engines/query engine Issue in the Query Engine tech/engines Issue for tech Engines.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants