V
V
Verkan2020-12-07 20:15:49
Performance evaluation
Verkan, 2020-12-07 20:15:49

Request one request or many?

There is a table of transactions. It is necessary to build a graph
. The first option is
to make a new request for each day and put it in the graph.
The second option
is to get all the transactions with one request and then divide using the laravel collection.

What is more productive? Many requests or Shipping percent. collection?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
FanatPHP, 2020-12-07
@FanatPHP

Three simple rules
1. Forget about performance issues. You can't think of anything smart anyway, and you don't even need to do stupid things
2. Don't invent phenomena that don't exist in nature like "Load a collection"
3. Instead of all these stupid fantasies , learn SQL .
Then the questions "how to get data for the chart" will not arise at all

N
N, 2020-12-07
@Fernus

Make a new request for each day and add it to the schedule

What does this mean in your case?
Do you have a day-by-day display on your page only for a certain period? Or how?
In any case, you only need to get from the database what you need right now for display ...
If you use "collections" by pushing all the data from the database there, then when there will be a "heap" of transactions ... then with each increase in this "heap" your collections will get slower, and CPU and RAM will suffer more and runtime will increase...
UPD:
...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question