Just need some clarification on my understanding.
Schema:
type Hotel {
name
}
type Room {
hotel
name
}
type Ledger {
hotel
room
createdTs
amount
}
type Cafe {
name
hotel
}
name: string @index(exact, term) .
hotel: uid @reverse .
room: uid @reverse .
createdTs: datetime @index(hour) .
amount: int @index(int) .
Query:
{
getRoomCountForAllHotels(func: eq(dgraph.type, "Hotel")) {
roomCount: count(~hotel) @filter(eq(dgraph.type, "Room"))
}
}
I’ve got 100 hotels, and each hotel has 1000 rooms and 1 cafe.
After a few minutes this returns a : context deadline exceeded
error.
I’m assuming because Badger is inspired by RocksDB which was inspired by LevelDB, the storage engine would be sort of a hexastore… is this true?
So then my intuition told me:
- Perhaps the query planner might use the indexed hexastore to find the hotels via Predicate(dgraph.type)-Object(“Hotel”)-Subject(uid) and load 100 of the hotel
uid
s into memory, - and for each of these hotel
uid
s, we’ll go into a nested loop and resolve their~hotel
via Predicate(hotel)-Object(hotel_uid)-Subject(room_uid or cafe_uid) which would bring up 100Kroom_uid
s and 100cafe_uid
s that would be loaded into memory. - Then we’d have to filter these 100K + 100 records by querying each of them (my goodness) via Subject(room_uid or cafe_uid)-Predicate(dgraph.type)-Object(“Room”) to make sure they’re a
dgraph.type
ofRoom
and notCafe
. - Then we’d sum them up according to their hotel
uid
(the RDBMS equivalent of GROUP BY) and return the values.
Am I sort of correct?