Welcome Guest, Not a member yet? Register   Sign In
Very slow if $data is big
#11

If you limit the results to let's say 200, is it still slow like you mentoined?

The request is indeed taking a great amount of time before it's presented..
If the database doesn't have any issues presenting the results this looks like a CI problem to me as well.
Reply
#12

Ok. I have done more tests. First of all, I've commented the other queries to test one thing at a time. I've also emptied the view to see only the header and footer.

With this modifications, the Request loading time is 4016.

With a limit of 200, it takes 3038 to Request to load.
With a limit of 100, it takes 2039 to Request to load.
With a limit of 10, it takes 1396 to Request to load.

When executing the full query in phpMyAdmnin, I have this:
Total of 415, processing in 0.0054 second(s).

It's very quick.

If I print the result object in PHP ($query->getResult()), the duration loading of Request is 35!

If I do this:


PHP Code:
$data['commandes_data']  $this->CommandesModel->get_commandes();
print_r($data['commandes_data']);exit; 


The duration of Request is 37.

The only code after this is sending $data to the view:
PHP Code:
return $this->template->renderConnected("commandes_view"$data); 


Here is the renderConnected() function:


PHP Code:
  public function renderConnected($view$data = [])
  {
    $data['site_title'] = 'Télé Ciné Montréal';
    $content  view('inc/header_connected'$data);
    $content .= view('inc/menu_connected'$data);
    $content .= view($view$data);
    $content .= view('inc/footer_connected'$data);
    return $content;
  


This function is in app/Libraries/Template.php file.
 
Does the problem comes from this function?

I also want to say that other pages with other queries are loading very fast, I have this problem with orders and invoices pages only, the pages like companies, projects, clients, etc. are loading at a normal pace.

Thank you so much for helping me with this!
--
MarieveStrange
Web Programmer
Reply
#13

Why don't you use renderSection() to include the header, menu & footer for your page?
> see: https://codeigniter4.github.io/userguide...youts.html

When you return only the results from the query to the Controller::methodName() (basicly without the view) and print_r or var_dump this, is it still that slow?
Reply
#14

Because I don't want to include header, menu and footer in every view files. But It gave me the idea of testing with the default loading view of CI:
PHP Code:
return view('commandes_view'$data); 

And it still very slow, so now I know that the problem doesn't come from my renderConnected() function.

To answer your second question, no, it's very fast with this in the controller:

PHP Code:
$data['commandes_data']  $this->CommandesModel->get_commandes();
print_r($data['commandes_data']);exit; 


After all the testing, the problem still seems to be with passing a big multiple array of multiple arrays and objects ($data) to the view. But only with the two pages that have the most values to show.

I don't know what I can do to make this faster. Maybe calling the datas with Ajax after the pages loads, so the $data variable passed to the view will me a much smaller and the Ajax calls return the data in JSON. I'll try this and let you know my conclusions. By then, if you have any suggestions, they are welcome.

Thanks again!
--
MarieveStrange
Web Programmer
Reply
#15

(Yesterday, 09:40 AM)MarieveStrange Wrote: Because I don't want to include header, menu and footer in every view files. But It gave me the idea of testing with the default loading view of CI:
PHP Code:
return view('commandes_view'$data); 

And it still very slow, so now I know that the problem doesn't come from my renderConnected() function.

To answer your second question, no, it's very fast with this in the controller:

PHP Code:
$data['commandes_data']  $this->CommandesModel->get_commandes();
print_r($data['commandes_data']);exit; 


After all the testing, the problem still seems to be with passing a big multiple array of multiple arrays and objects ($data) to the view. But only with the two pages that have the most values to show.

I don't know what I can do to make this faster. Maybe calling the datas with Ajax after the pages loads, so the $data variable passed to the view will me a much smaller and the Ajax calls return the data in JSON. I'll try this and let you know my conclusions. By then, if you have any suggestions, they are welcome.

Thanks again!

Do you have a single array example what data you are pushing to the view from the 415 results?
Without personal client information of course.

To answer the view
It's not required to use this on every view, you can extend() this when needed.
I've got a order to PDF generator that holds different HTML header/footer all other content can be extended when needed.

Using this solution to do that, that's pretty fast on my side:
> see: https://codeigniter.com/user_guide/outgo...arser.html
Reply
#16

The array that I'm passing to the view is too big to send it to you. And, of course, it contain a bunch of sensible datas.

Thanks for the view parser link, I'm gonna look at it.

Since the problem seems to come from $data passed to the view, I'm loading the view without calling the queries, loading an empty DataTable that is retrieving datas via Ajax. Now, the loading speed is ultra fast!

I have other pages that loads a lot of datas, for those who are not with DataTable, I'm gonna simply load the datas with Ajax and do the logic from there. I have a lot of work to do in multiple pages but it worth it for the speed I'll gain!

Thanks again superior for your guidance, it helped me a lot!
--
MarieveStrange
Web Programmer
Reply




Theme © iAndrew 2016 - Forum software by © MyBB