Question: I'm trying to send image as bytes because bandwidth is being killed by base64 strings. I've seen examples about transferring it as stream
<https://stackoverflow.com/a/17573179/8359785> but the problem is that I'm not sure how to transfer json data with it at the same http request

Answer: 
> 
> 1. Although my query is selecting only required columns, it is taking forever. But his query, which takes all the columns of the joined
>  table executes faster. Why is that happening?
> 
> 
> 

Even though your query is only selecting a few columns, it does a lot of sub-queries to the table that, if they don't have a proper index, will cause a long run time execution.

His query is faster because the way `laravel` do `eager loading`. Laravel do not do sub-queries on the same query, it does a lot of query and the make a relation using collections. What I mean is basically that your query runs a lot of inside queries while your partner's do multiple queries and then merge them using collections

> 
> 2. What difference does it make to run a query on different machines, the time difference should be that significant?
> 
> 
> 

Also, there may be some difference if the queries are running locally. Usually SQL consults take ram and processor power to do searching and joining, so if your PC is running low for whatever reason it will take more time than a PC in the right conditions. But if the SQL machine is in the cloud there shouldn't be any difference in execution
The reason why second query is faster is it's using **eager loading**

it eager loads relationships

Take a look at this link
 [Eager Loading](https://laravel.com/docs/5.5/eloquent-relationships#eager-loading)