Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FetchPlan not working #50

Open
Ostico opened this issue Oct 10, 2015 · 8 comments
Open

FetchPlan not working #50

Ostico opened this issue Oct 10, 2015 · 8 comments

Comments

@Ostico
Copy link
Owner

Ostico commented Oct 10, 2015

Moved from
orientechnologies#11

@DJWassink
Copy link

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.

@Ostico
Copy link
Owner Author

Ostico commented Nov 9, 2015

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.

@sameer-shelavale
Copy link
Contributor

sameer-shelavale commented Dec 9, 2016

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 ?

@Ostico
Copy link
Owner Author

Ostico commented Dec 10, 2016

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.

@sameer-shelavale
Copy link
Contributor

ok,
But will it lead to lesser efficiency for very high load website ??

@andreyvk
Copy link

andreyvk commented Dec 10, 2016 via email

@Ostico
Copy link
Owner Author

Ostico commented Dec 10, 2016

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.

@daniel-zahariev
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants