Emysql:ping VS without Ping

Source: Internet
Author: User

Emysql The database is ping once every time the SQL is executed, it's strange! I don't know why.

Here's a rough look at the efficiency test:

The table is as follows:


Mysql> Show CREATE TABLE just_test\g;
1. Row ***************************
Table:just_test
Create table:create Table ' just_test ' (
' ID ' bigint (unsigned) is not NULL,
' Data ' int (one) is not NULL,
' Update_time ' timestamp not NULL DEFAULT current_timestamp on update current_t
Imestamp,
PRIMARY KEY (' id ')
) Engine=innodb DEFAULT Charset=utf8 Collate=utf8_bin
1 row in Set (0.02 sec)

Under the 64-bit Win7 system (Cpu:intel (R) Core (TM) i3 CPU [email protected] 2.93GHz, Memory: 8G),

Create the table, insert a record, and then repeat update the table's data field is a value (SQL such as: Update just_test Set data = 456),

Results:

========with Ping (Ping once before each update) test results: ========

Fg_sql_inf:prof (100).
Loops, using TIME:63MS
Ok
2> fg_sql_inf:prof (100).
Loops, using Time:94ms
Ok
3> fg_sql_inf:prof (100).
Loops, using time:125ms
Ok
4> fg_sql_inf:prof (100).
Loops, using time:78ms
Ok
5> Fg_sql_inf:prof (10000).
10000 loops, using time:4010ms
Ok
6> Fg_sql_inf:prof (10000).
10000 loops, using time:3978ms
Ok
7> Fg_sql_inf:prof (10000).
10000 loops, using time:3838ms
Ok
8> Fg_sql_inf:prof (10000).
10000 loops, using time:3994ms
Ok
9> Fg_sql_inf:prof (10000).
10000 loops, using time:4009ms
Ok
10> Fg_sql_inf:prof (10000).
10000 loops, using TIME:3853MS
Ok
11> Fg_sql_inf:prof (10000).
10000 loops, using time:3838ms
Ok
12> Fg_sql_inf:prof (10000).
10000 loops, using time:3947ms
Ok
13> Fg_sql_inf:prof (10000).
10000 loops, using time:4025ms
Ok
14> Fg_sql_inf:prof (10000).
10000 loops, using time:4025ms
Ok
15> Fg_sql_inf:prof (10000).
10000 loops, using time:3869ms
Ok
16> Fg_sql_inf:prof (10000).
10000 loops, using TIME:3993MS
Ok
17> Fg_sql_inf:prof (10000).
10000 loops, using TIME:3853MS
Ok
18> Fg_sql_inf:prof (10000).
10000 loops, using time:3947ms
Ok
19> fg_sql_inf:prof (100000).
100000 loops, using time:39359ms
Ok
20> fg_sql_inf:prof (100000).
100000 loops, using time:39328ms
Ok
21> fg_sql_inf:prof (100000).
100000 loops, using time:39187ms
Ok
22> fg_sql_inf:prof (100000).
100000 loops, using time:39406ms
Ok
23> fg_sql_inf:prof (100000).
100000 loops, using time:39265ms
Ok
24> fg_sql_inf:prof (100000).
100000 loops, using time:39515ms
Ok

======== without ping (does not include ping) test results ========

2> fg_sql_inf:prof (100).
Loops, using Time:46ms
Ok
3> Fg_sql_inf:prof (10000).
10000 loops, using time:2308ms
Ok
4> Fg_sql_inf:prof (10000).
10000 loops, using time:2402ms
Ok
5> Fg_sql_inf:prof (10000).
10000 loops, using time:2418ms
Ok
6> Fg_sql_inf:prof (10000).
10000 loops, using time:2419ms
Ok
7> Fg_sql_inf:prof (10000).
10000 loops, using time:2417ms
Ok
8> Fg_sql_inf:prof (10000).
10000 loops, using time:2419ms
Ok
9> Fg_sql_inf:prof (10000).
10000 loops, using time:2294ms
Ok
10> Fg_sql_inf:prof (10000).
10000 loops, using time:2417ms
Ok
11> Fg_sql_inf:prof (10000).
10000 loops, using time:2479ms
Ok
12> Fg_sql_inf:prof (10000).
10000 loops, using TIME:2433MS
Ok
13> Fg_sql_inf:prof (10000).
10000 loops, using TIME:2403MS
Ok
14> fg_sql_inf:prof (100000).
100000 loops, using time:23540ms
Ok
15> fg_sql_inf:prof (100000).
100000 loops, using time:23556ms
Ok
16> fg_sql_inf:prof (100000).
100000 loops, using time:23759ms
Ok
17> fg_sql_inf:prof (100000).
100000 loops, using time:23510ms
Ok
18> fg_sql_inf:prof (100000).
100000 loops, using time:23667ms
Ok
19> fg_sql_inf:prof (100000).
100000 loops, using time:26786ms
Ok
20> fg_sql_inf:prof (100000).
100000 loops, using time:23618ms
Ok
21> fg_sql_inf:prof (100000).
100000 loops, using time:23525ms
Ok

As can be seen, the operation of the ping has a certain effect, after removing the ping, it will probably speed up 80%

Report:

UPDATE_TEST_TBL (_newval)
Table = Just_test,
Tablebin = Atom_to_binary (Table, Latin1),

CMD = << "Update", Tablebin/binary, "Set data = 456" >>

Execute (CMD). % will call Emysql:execute (? POOL, CMD)

Prof (Times)
F = Fun ()
UPDATE_TEST_TBL (1)
End
Run (F, times).


Run (fun, Loop)
Statistics (Wall_clock),
For (1, loops, fun),
{_, T1} = statistics (Wall_clock),
Io:format ("~p loops, using time: ~pms~n", [Loop, T1]),
Ok.

For (Max, Max, fun)
Fun ();
For (I, Max, Fun)
Fun (),

for (I + 1, Max, fun).

Emysql:ping VS without Ping

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.