Open Ostico opened 8 years ago
Seeing the same issue with the following query:
select EXPAND(IN('Member')) from #12:0 fetchplan out_Member:2
Where the id is from a User
which has incoming edges called Member
coming from a class called Group
, then fetch(plan) other members from that Group
.
On the Orient console this returns a Group
with populated User
fields, on PhpOrient the bag stays empty.
Hi @DJWassink , @bazo , @irshadhasmat , the binary protocol does not return fetched data for the bags but only their ID, also for specified fetch plan.
Now i load them when the ridBag is iterated, updating it's content.
hi @Ostico ,
I am trying to do a simple query with *:1
fetch plan
$client->query("Select from School", 20, '*:1' );
Here, School class has some fields which are linked to other records of other classes
but it does not return the expanded details of those linked fields,
is it not working because of this same bug ?
Hi @sameer-shelavale ,
yes this is the same behaviour. The OrientDB binary protocol do not load ( expand ) automatically the bags. But you can cycle on them and they should be loaded.
ok, But will it lead to lesser efficiency for very high load website ??
Sameer, it depends on how high of a load you are talking about.
We ourselves were forced to cycle through bags ourselves and the efficiency is acceptable. Besides, if you are running OrientDB locally, there's no problem really.
On Sat, Dec 10, 2016 at 8:16 PM, Sameer Shelavale notifications@github.com wrote:
ok, But will it lead to lesser efficiency for very high load website ??
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Ostico/PhpOrient/issues/50#issuecomment-266211685, or mute the thread https://github.com/notifications/unsubscribe-auth/ABWZUt-3kJa6o_pLHgH5E0TsC1ro4LXXks5rGrRQgaJpZM4GMloZ .
In my opinion, the load should be only a little bit higher than a native implementation. As @andreyvk said, it depends on how high the load is. I also recommend to have your database on the same LAN of your application server.
BTW, the returned payload are pretty the same in both cases. The socket and the connection are already established, so no delay on that.
The only difference are the number of the requests payloads versus the database and the parsing time and data retrieve on the database itself.
But, there is no solution for that.
I did some digging before i found this issue and i found that here there is functionality for getting the prefetched records but it is only available via callbacks. Here's a sample code of how i made it work for me:
// Store the prefetched records
$prefetched_records = [];
$cachePrefetched = function (Record $record) use (&$prefetched_records) {
$prefetched_records[(string)$record->getRid()] = $record;
};
// Use with record load
$record_params = array('fetch_plan' => '*:-1', '_callback' => $cachePrefetched);
$book = $orient_db->recordLoad(new ID(50, 0), $record_params)[0];
// Use with query - has to be async
$books_params = array('limit' => 20, 'fetch_plan' => '*:-1', '_callback' => $cachePrefetched);
$books = $orient_db->queryAsync('SELECT * FROM Books', $books_params);
// now all of the records in the the `authors` linklist are loaded in the $prefetched_records
// and can be populated to generate the output result
Moved from https://github.com/orientechnologies/PhpOrient/issues/11