neoxygen / neo4j-neoclient

Simple PHP HttpClient for the Neo4j ReST API with Multi DB Support
MIT License
121 stars 138 forks source link

very slow response time #63

Closed szewang2805 closed 8 years ago

szewang2805 commented 8 years ago

hello, i have installed and everything is fine except the response from neo4j (local) is very slow. i wait about 3-5 second to get a response even it is very simple query ,can you solve it? thanks

ikwattro commented 8 years ago

Hi,

What is your query ? What is the size of your database and the neo4j settings ?

szewang2805 commented 8 years ago

i just query a simple 1 node, and return it. my neo4j version is 2.1 which setting i need to do if i want a faster response HTTP ?

ikwattro commented 8 years ago

Normally it should run in less than 10ms.

What is your full Neo4j version ? Not that neoclient is only compatible with Neo4j 2.1.6 and above.

What is your full query ?

Do you have indexes ?

szewang2805 commented 8 years ago

i am using 2.1.8 new installation Neo4j in my DB, i only have two nodes.

$client = ClientBuilder::create() ->addDefaultLocalConnection() ->setAutoFormatResponse(true) ->build(); $query = 'MATCH (n) RETURN n LIMIT 100'; $transaction = $client->createTransaction(); $transaction->pushQuery($query); $transaction->commit(); $all = $transaction->getResults (); foreach ($all as $each){ print_R($each->getTableFormat()); }

result Array ( [0] => Array ( [n] => Array ( [name] => World ) ) [1] => Array ( [n] => Array ( [name] => World ) ) )

ROOT information Neoxygen\NeoClient\Request\Response Object ( [body:protected] => Array ( [management] => http://localhost:7474/db/manage [data] => http://localhost:7474/db/data )

[rows:protected] => 
[result:protected] => Neoxygen\NeoClient\Formatter\Result Object
    (
        [nodes:protected] => Array
            (
            )

        [relationships:protected] => Array
            (
            )

        [errors:protected] => 
        [identifiers:protected] => Array
            (
            )

        [tableFormat:protected] => 
    )

)


am i need to skip this wrapper?

the two nodes can be printed out, but the php keep connects to localhost for 5 seconds for getting two result.

but i notice that when i push 10 queries in one commit, the response time is still the same. that why i think there should be some setting need to be fixed on server (local)

thanks

ikwattro commented 8 years ago

This is normal, you are issuing 3 http requests. The need for creating transactions manually is more an advanced use case, you can just do this that will do all 3 steps in one :

$query = 'MATCH (n) RETURN n LIMIT 100';
$result = $client->sendCypherQuery($query)->getResult();