firebase-php icon indicating copy to clipboard operation
firebase-php copied to clipboard

Slow query

Open harding13 opened this issue 7 years ago • 8 comments

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?

harding13 avatar Oct 23 '17 15:10 harding13

Same here, I'm reading a /records/rec_id/node_id and it takes 300-700ms, however on the firebase profiler, it shows 0ms.

ova-adam avatar Nov 10 '17 20:11 ova-adam

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 avatar Nov 11 '17 00:11 ova-adam

@ova-adam so there is nothing to do?

harding13 avatar Nov 12 '17 09:11 harding13

@harding13 there is, CURL requests are very slow as you can see. Is this an issue of CURL or FB at the core?

ova-adam avatar Nov 12 '17 22:11 ova-adam

I see it but i don't know how to solve it :)

harding13 avatar Nov 13 '17 07:11 harding13

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.

ova-adam avatar Nov 13 '17 08:11 ova-adam

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)

harding13 avatar Nov 13 '17 08:11 harding13

@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

mastef avatar Jun 18 '19 02:06 mastef