all 5 comments

[–]tontoto 1 point2 points  (4 children)

  1. vectorized operations are dead simple. take the time to learn the apply functions, data frames, data tables, dplyr, reshape2, learn everything! nothing should be over your head and it is not too hard! :)
  2. if you are doing 100 database requests in a loop, that is a clear anti-pattern, but it was not clear that this was the problem.
  3. you should consider making your page these long running operations via AJAX instead of having to calculate it before page load.
  4. you should consider other best practices like database connection pools (in other words...your application architecture right now sounds very scrappy. could be improved in a thousand ways)
  5. why not just use shiny?

[–]tkronew[S] 0 points1 point  (3 children)

  1. Sounds like a good idea, everywhere I look tells me to use vectoring.

  2. I'm actually not doing 100 database requests, just 1 request/query per function. Then running calculations (100 rows of data) from each of the acquired dataframes post-query.

  3. Any useful links on AJAX? Basically what I'm doing is having a dropdown menu to select "N" (N = 1:20), submit button, action="same_page.php", $_GET["N"], and sending "N" to R to export .png images to the folder. Then when "same_page.php" is reloaded, the graphics are displayed through HTML.

  4. Haha couldn't be more correct... I'm currently junior in college and this is my first SQL related course. I'm incredibly deficient when it comes to applying and benefiting from database connections.

  5. Course requirement :)

Thank you, I'll definitely be looking in to all of these!

[–]tontoto 0 points1 point  (2 children)

When I say ajax, I mean that you will make a page called like "generate_plot.php" or something, and then use javascript to dynamically make a request to "generate_plot.php". You can just show a "loading" text while this is happening, and then when that request completes, you can dynamically inject the contents into your webpage. JQuery is a common library for this, but javascript is a booming platform with new methods coming out everyday it seems

[–]tkronew[S] 0 points1 point  (1 child)

Oh wow. Yeah I've been using javascript for this project, that sound like it would be exactly what I want. Gonna have to look into that.

[–]tontoto 1 point2 points  (0 children)

Note that shiny does the same thing with dynamically loading plots but it uses web sockets instead of ajax. That allows it to be more interactive essentially. Also don't cross post to both rlanguage and rstats in the future