Problems with PHP storage database efficiency
八哥
八哥 2023-09-22 22:46:18
0
0
785

Program 1:

for($i=0;$<100;$){

Connect to the database;

Execute select in advance by a value;

Disconnect from the database;

Connect to the database;

Execute updata once to store data;

Disconnect from the database;

}

The program execution takes about 1.5-2 seconds

Program 2:

Connect to the database;

for($i=0;$i<100;$ i){

Execute select once;

Execute update once;

}

Disconnect the database connection;

Execution time-consuming 0.05-0.09 seconds

The key is that my storage database program is an interface document. The program will be executed only when someone else submits a post. Thousands of users will submit posts every second. How can I create a pdo? How about permanently connecting to improve storage efficiency? The program ends after returning the result to the post submitter, and the session or pdo connection is automatically closed.

八哥
八哥

reply all(0)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!