Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

swing worker in php ?

 
Georgios Chatziefstratiou
Ranch Hand
Posts: 106
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there


Example i have 50.000 rec and i want to export them and still access the application.I use an Api but i have try with also with sql query .

The query joins about 3 -4 tables and it takes some time. Both of them take time(a lot)!!!

in Java there is a swing worker class if you want to have something done (in background) and still access the application is there something similar in php.

I have to optimize query so on but what else can i do any ideas ?


thanks
 
K. Tsang
Bartender
Posts: 3444
13
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PHP has threads too similar to java. The PHP library for multi-threading is "pthreads" containing classes like Thread, Worker, Threaded etc

Have a look at the pthreads library

By the way I didn't use such library before.
 
Georgios Chatziefstratiou
Ranch Hand
Posts: 106
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K. Tsang wrote:PHP has threads too similar to java. The PHP library for multi-threading is "pthreads" containing classes like Thread, Worker, Threaded etc

Have a look at the pthreads library

By the way I didn't use such library before.



what have you use then ?How can i optimized the Api or the Query now is 50000 tomorrow is 150000 . Any ideas ?
 
K. Tsang
Bartender
Posts: 3444
13
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the query optimization, look into adding indexes. But first try to get an execution plan of the sql from the database using the "explain" command.

What database are you using? If MySQL have a look at here for more info.
 
Georgios Chatziefstratiou
Ranch Hand
Posts: 106
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K. Tsang wrote:For the query optimization, look into adding indexes. But first try to get an execution plan of the sql from the database using the "explain" command.

What database are you using? If MySQL have a look at here for more info.

yes i use Mysql and i have already look "explain " something else?
 
K. Tsang
Bartender
Posts: 3444
13
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Going back to the very beginning. You mentioned you are joining 3-4 tables. 50K records becomes 150K? How are you joining the tables? left join, inner join

Since you gone over the explain optimization stuff, I suppose you have taken action with the suggestions from the execution plan.

You plan to export the data but doing "all" records (eg 50K+) in one go is indeed disk I/O intensive. Doing this in chunks would probably improve the performance.

Furthermore, you should know the data size of each record (export a multiple factor) should again improve.

Lastly partitioning table by date or something may be possible.

Your issue is more of a database issue rather than PHP.
 
Georgios Chatziefstratiou
Ranch Hand
Posts: 106
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K. Tsang wrote:Going back to the very beginning. You mentioned you are joining 3-4 tables. 50K records becomes 150K? How are you joining the tables? left join, inner join

Since you gone over the explain optimization stuff, I suppose you have taken action with the suggestions from the execution plan.

You plan to export the data but doing "all" records (eg 50K+) in one go is indeed disk I/O intensive. Doing this in chunks would probably improve the performance.

Furthermore, you should know the data size of each record (export a multiple factor) should again improve.

Lastly partitioning table by date or something may be possible.

Your issue is more of a database issue rather than PHP.



50 k maybe sometime 150k it depends mostly is 50k.

This is done by the application Api not by joining i have use the explain with a join created by me to see the difference.

I have also change "Apache" with "nginx" which has better results with the persistence Api the Application use.

I will cut the Api that i use and do it otherwise, with a function or left join which as i have seen was very fast .

I have the results in 3 min from test .

You are right its db issue.

Thanks

 
K. Tsang
Bartender
Posts: 3444
13
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great you found the root cause.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic