It takes 1,066,956,371ns. That’s about 500x slower. It’s as if the name index is not being used. Is that correct? Why would it not use the index and then filter the results?
I am using the latest docker images and querying through the web client. 2 million vertexes are loaded.
I’m not qualified to answer this, but out of curiousity what is the index type: term, fulltext, hash, or exact? And “Aqualung” has the dgraph.type set to “Album”?
and the dgraph.type is “Album”. There are 2 items with different types with name “Aqualung” (Album and Track) and this returns just the Album. The query works just incredibly slow…
At least I think it is set by default. I’m not sure.
If you export your dataset. And import it to a new instance of v1.1.1 and a new instance of the latest one. And compare the performance of both. Well, my theory is right.
But, it is important to export and create both new instances. To not have a bias.
If this comes to be true, well please open an issue requesting a way to make this optional.
If I had a dataset that I could compare and get the same numbers as yours, I would do the tests myself.
If name is indexed and we anchor on that it seems the additional filter (especially in this case where only a few items are returned for the name lookup) should be pretty fast. Again, it looks like the addition of the filter is disabling the initial index lookup against name. I am speculating here but the numbers seem to backup it up. If so something seems off with that approach.
As far as I remember this it’s a very old topic, look at this post.
It seems that every filter you add will look at the entire index list, so I even if your main filter returns one node, consecutive filters will hit the index table.
The linked post is about filtering on edge facets and indicates this was fixed in 1.2, so this is not likely the same scenario unless I am missing something.
@mrjn or @dmai it would be nice to get an explanation of why this operations is so slow. I am willing to share my data and schema if it helps.
Note I am currently evaluating Dgraph for a project at my company. This seems like a simple query that should perform. If I cannot figure out what is wrong soon we would pass on Dgraph.
Thanks. I will try this and report results back (loading data now).
Still confused as to why the initial index lookup would not take precedence. Yes there are a lot of tracks (1 million+) but the index lookup against name returns 2 nodes 1 of which is a Track.
I will admit I am new to Dgraph, RDF, and GraphQL. I however have extensive experience using Gremlin and Cypher.
The query is run exactly how it was written. The original query would use the name index to get the nodes matched by "Aqualung" (eq(name, "Aqualung")), then use another index to get the nodes of type Album (type(Album)), and then intersect these two lists of UIDs to perform the filter.
Once there’s a query planner in place (TBD on the 2020 Dgraph roadmap) Dgraph can be smarter about executing your original query.
Your right Orlando. I’ll echo a comment from that post that seems applicable more then a year later:
anyway, it looks like a timebomb, because a lot of people who use filters don’t understand how they actually works, and it works well only while they have small amount of data.
I do want to say that I do appreciate the effort of the Dgraph team and am continuing my evaluation. The above issue is relatively small in the grand scheme of things and you all provided a working solution. So thanks guys.