0

I am to generate a report from the database with 1000's of records. This report is to be generated on monthly basis and at times the user might want to get a report spanning like 3 months. Already as per the current records, a month's data set can reach to like 5000.

I am currently using vue-excel to which makes an api call to laravel api and there api returns the resource which is now exported by vue-excel. The resource does not only return the model data but there are related data sets I also need to fetch.

This for smaller data sets works fine that is when I am fetching like 3000 records but for anything larger than this, the server times out.

I have also tried to use laravel excel with the query concern actually timed them and both take same amount of time because laravel excel was also mapping to get me the relations.

So basically, my question is: is there some better way to do this so as get this data faster and avoid the timeouts

Johhn
  • 979
  • 17
  • 24
  • If the server is timing out, you might want to look into optimising your database queries. Check if you have any n+1 issues. See if you can adjust your indexes to improve performance. Look into caching. Etc. – Peter Mar 29 '19 at 18:28
  • what do you mean by adjusting my indexes? – Johhn Mar 29 '19 at 19:50
  • You may need to add some indexes on some columns if your queries would benefit from them. It's hard to say what you should do without seeing the migrations, models and queries you are using. – Peter Mar 29 '19 at 19:53

1 Answers1

0

just put this on start of the function

    ini_set(max_execution_time, 84000); //84000 is in seconds

this will override the laravel inbuild script runtime max value.

iamawesome
  • 652
  • 7
  • 15
  • I am avoiding this, I don't want to change the execution time, what I want is probably the best way to do this, how to best fetch records with relationships probably chunking, though I don't understand chunking very well – Johhn Mar 30 '19 at 10:04
  • then you should post your query here, otherwise how will one understand – iamawesome Mar 30 '19 at 10:15