firebase-php
firebase-php copied to clipboard
Slow query
Hi all
i'm using firebase-php to make a query against a firebase db where i stored chat data.
the structure is a thing like this
chat
----chat_ID
------------node_ID
when i search into a chat (with one or many children) with a code like this
$firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN);
$value = $firebase->get('/chat/'.$chat, array('orderBy' => '"status"', 'equalTo' => '"unread"'));
the query needs almost 700ms to get a result (even if there is only one node)
I think it's too much... or not?
Same here, I'm reading a /records/rec_id/node_id and it takes 300-700ms, however on the firebase profiler, it shows 0ms.
Looks to be a CURL issue, here are some stats from when I log with curl:
time_namelookup: 0.153
time_connect: 0.161
time_appconnect: 0.357 time_pretransfer: 0.357 time_redirect: 0.000 time_starttransfer: 0.408 ---------- time_total: 0.408
@ova-adam so there is nothing to do?
@harding13 there is, CURL requests are very slow as you can see. Is this an issue of CURL or FB at the core?
I see it but i don't know how to solve it :)
Is this an issue with this library, firebase, or curl? This long lag doesn't happen if I curl a website like Google.com
If this can't be eliminated, this is a deal breaker for our project.
I choosed Firebase because of its speed. But if i must wait 0.7 sec for every query, maybe, i must switch to another technology (or another way of using FB)
@ova-adam @harding13 Since your issue the library has been also updated so the curl handle is re-used for consecutive requests, which should reduce your connection times to the firebase server for repeat queries.
A few other things that improved connection times drastically I've mentioned here: https://github.com/ktamas77/firebase-php/issues/68#issuecomment-502921193
Related SO : https://stackoverflow.com/a/26568867/10728554