Performance issue of aggregation in only v21.12.0

Report a Dgraph Bug

What version of Dgraph are you using?

  • dgraph/standalone:v21.12.0 running on the top of docker engine in a Macbook(10.13)
  • dgraph/dgraph:v21.12.0 running in cluster mode in GKE

Have you tried reproducing the issue with the latest release?

Yes, it is an issue happening only in the latest release.

What is the hardware spec (RAM, OS)?

Macbook(10.13, 8GB, 2.6 GHz Intel Core i5)

Steps to reproduce the issue (command/config used to run Dgraph).

  1. launch both dgraph/standalone:v21.12.0 and dgraph/standalone:v21.03.0

  2. restore schema and data from this snapshot into both versions of dgraph. (I am new user here so this link is from my google drive)

  3. make the following query to both versions of dgraph.

query chapters_with_release_date(
	$today: string = "2020-12-20T23:00:00Z"
) {
  chapters(func: type(Chapter), first: 10) @cascade {
    xid
    chapter.video @filter(le(video.release_date, $today)) {
        xid
        RD as video.release_date
    }
    chapter_release_date: max(val(RD))
  }
}
  1. compare the server_latency in the query results from both version of dgraph.

Additional infos:
schema:

type Video {
    xid
    video.chapters
    video.release_date
}

type Chapter {
    xid
    chapter.video
}

xid: string @index(hash) @upsert . 
video.chapters: [uid] .
video.release_date: datetime @index(hour) .
chapter.video: uid .

data size:

  • Video: 35552
  • Chapter: 35552

Expected behaviour and actual result.

Results from my local Macbook(10.13, 8GB, 2.6 GHz Intel Core i5)

  • server_latency(v21.3.0): 1.5 ~ 2 seconds
  • server_latency(v21.12.9): 30~40 seconds, and the latency is sensitive to the data size. It is a huge performance degradation.

I also found the performance bottleneck could be max(…) aggregation in the query. The following query without aggregation responds in 2~4 seconds.

query chaptersWithoutAggr(
	$today: string = "2020-12-20T23:00:00Z"
) {
  chapters(func: type(Chapter), first: 10) @cascade {
    xid
    chapter.video @filter(le(video.release_date, $today)) {
        xid
        RD: video.release_date
    }
    # chapter_release_date: max(val(RD))
  }
}
1 Like