Load time for php function

Hi,

I select the values from a table and display them, than insert the returned values in another table. I am using a function to insert the values. The function is insertvalues($rows). So my query is:

SELECT (row1, row2) FROM (mytable) WHERE id=x;
WHILE (something) {
echo "rows";
insertvalues($rows);
}

This takes 4 seconds to load. But if I dont use the function and insert the values right from there itself, the page takes 1 second to load. I always thought that using a function to breakdown multiple tasks is advisable. But its taking a lot of time. Should I continue to insert the values from the while loop itself?

Have you considered using a “SELECT-INSERT” query?

1 Like

What does the insertvalues() function do, code-wise? It seems strange that just calling a function would cause it to slow down so much.

But as @spacephoenix said, combining the two queries into one would probably be faster again.

1 Like

Thanks for your advice @SpacePhoenix … I tried combining them and it loads in 1 second.

Have a nice one !
:slight_smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.