While reading Graph Databases book, I came across this excerpt:
I can't figure out why the second query is more expensive than the first.
Indeed, both filter on the
May anyone explain it?
The book is assuming that PersonFriend is indexed on PersonID, but not on FriendID. It also seems to assume that Person indexes PersonID and Person independently.
If this is the case, the first query comes back as
Then the second comes back as
This would be an elementary relational database design error. With a relationship table like this you would always index all keys, and the performance profile for both queries would be indistinguishable (ignoring variations in value distributions, etc).
At this point it sounds like the author is trying to show that relational databases are intrinsically deficient.