sourcenetwork / defradb

DefraDB is a Peer-to-Peer Edge Database. It's the core data storage system for the Source Network Ecosystem, built with IPLD, LibP2P, CRDTs, and Semantic open web properties.
401 stars 40 forks source link

Creating document from primary side of one-one very very slow #2968

Open AndrewSisley opened 3 weeks ago

AndrewSisley commented 3 weeks ago

Creating a document from the primary side of a one-one is very very slow. When running the below queries, the Player collection is empty, and Contact has 37384 documents.

Over the http client the below takes about 8ms:

mutation {
  create_Player(
    input: { email: "test2" }
  ) {
    _docID
  }
}

However, the below takes about 500ms, and gets slower the more Players are created:

mutation {
  create_Player(
    input: { email: "test", contact_id: "bae-000163f5-a445-5909-ae67-2958d02a74dc" }
  ) {
    _docID
  }
}

Schema (trimmed):

type Player {
  email: String @index(unique: true)
  contact: Contact @primary @relation(name: "playerContact")
}

Adding an index to contact_id does not appear to improve things.

Flagged as a bug, as this is far slower than is reasonable, suggesting there is a bug in the code somewhere.

fredcarle commented 1 week ago

This was initially raised by @islamaliev in June https://github.com/sourcenetwork/defradb/issues/2690