( ! ) Deprecated: Function WP_Dependencies-&gt;add_data() was called with an argument that is <strong>deprecated</strong> since version 6.9.0! IE conditional comments are ignored by all supported browsers. in /var/www/html/wp-includes/functions.php on line 6131
Call Stack
#TimeMemoryFunctionLocation
10.0000484048{main}( ).../index.php:0
20.0000484400require( '/var/www/html/wp-blog-header.php ).../index.php:17
30.11554103728require_once( '/var/www/html/wp-includes/template-loader.php ).../wp-blog-header.php:19
40.11664132720include( '/var/www/html/wp-content/themes/twentyfifteen/single.php ).../template-loader.php:125
50.11664132720get_header( $name = ???, $args = ??? ).../single.php:10
60.11664132936locate_template( $template_names = [0 => 'header.php'], $load = TRUE, $load_once = TRUE, $args = [] ).../general-template.php:48
70.11674133032load_template( $_template_file = '/var/www/html/wp-content/themes/twentyfifteen/header.php', $load_once = TRUE, $args = [] ).../template.php:749
80.11674133576require_once( '/var/www/html/wp-content/themes/twentyfifteen/header.php ).../template.php:814
90.11684140984wp_head( ).../header.php:18
100.11684140984do_action( $hook_name = 'wp_head' ).../general-template.php:3197
110.11684141200WP_Hook->do_action( $args = [0 => ''] ).../plugin.php:522
120.11684141200WP_Hook->apply_filters( $value = '', $args = [0 => ''] ).../class-wp-hook.php:365
130.11704144616wp_enqueue_scripts( '' ).../class-wp-hook.php:341
140.11704144616do_action( $hook_name = 'wp_enqueue_scripts' ).../script-loader.php:2311
150.11704144832WP_Hook->do_action( $args = [0 => ''] ).../plugin.php:522
160.11704144832WP_Hook->apply_filters( $value = '', $args = [0 => ''] ).../class-wp-hook.php:365
170.11714146720twentyfifteen_scripts( '' ).../class-wp-hook.php:341
180.11734148240wp_style_add_data( $handle = 'twentyfifteen-ie', $key = 'conditional', $value = 'lt IE 9' ).../functions.php:440
190.11734148240WP_Styles->add_data( $handle = 'twentyfifteen-ie', $key = 'conditional', $value = 'lt IE 9' ).../functions.wp-styles.php:245
200.11734148240WP_Dependencies->add_data( $handle = 'twentyfifteen-ie', $key = 'conditional', $value = 'lt IE 9' ).../class-wp-styles.php:385
210.11734148240_deprecated_argument( $function_name = 'WP_Dependencies->add_data()', $version = '6.9.0', $message = 'IE conditional comments are ignored by all supported browsers.' ).../class-wp-dependencies.php:317
220.11734154192wp_trigger_error( $function_name = '', $message = 'Function WP_Dependencies->add_data() was called with an argument that is <strong>deprecated</strong> since version 6.9.0! IE conditional comments are ignored by all supported browsers.', $error_level = 16384 ).../functions.php:5925
230.11734273728trigger_error( $message = 'Function WP_Dependencies-&gt;add_data() was called with an argument that is <strong>deprecated</strong> since version 6.9.0! IE conditional comments are ignored by all supported browsers.', $error_level = 16384 ).../functions.php:6131

( ! ) Deprecated: Function WP_Dependencies-&gt;add_data() was called with an argument that is <strong>deprecated</strong> since version 6.9.0! IE conditional comments are ignored by all supported browsers. in /var/www/html/wp-includes/functions.php on line 6131
Call Stack
#TimeMemoryFunctionLocation
10.0000484048{main}( ).../index.php:0
20.0000484400require( '/var/www/html/wp-blog-header.php ).../index.php:17
30.11554103728require_once( '/var/www/html/wp-includes/template-loader.php ).../wp-blog-header.php:19
40.11664132720include( '/var/www/html/wp-content/themes/twentyfifteen/single.php ).../template-loader.php:125
50.11664132720get_header( $name = ???, $args = ??? ).../single.php:10
60.11664132936locate_template( $template_names = [0 => 'header.php'], $load = TRUE, $load_once = TRUE, $args = [] ).../general-template.php:48
70.11674133032load_template( $_template_file = '/var/www/html/wp-content/themes/twentyfifteen/header.php', $load_once = TRUE, $args = [] ).../template.php:749
80.11674133576require_once( '/var/www/html/wp-content/themes/twentyfifteen/header.php ).../template.php:814
90.11684140984wp_head( ).../header.php:18
100.11684140984do_action( $hook_name = 'wp_head' ).../general-template.php:3197
110.11684141200WP_Hook->do_action( $args = [0 => ''] ).../plugin.php:522
120.11684141200WP_Hook->apply_filters( $value = '', $args = [0 => ''] ).../class-wp-hook.php:365
130.11704144616wp_enqueue_scripts( '' ).../class-wp-hook.php:341
140.11704144616do_action( $hook_name = 'wp_enqueue_scripts' ).../script-loader.php:2311
150.11704144832WP_Hook->do_action( $args = [0 => ''] ).../plugin.php:522
160.11704144832WP_Hook->apply_filters( $value = '', $args = [0 => ''] ).../class-wp-hook.php:365
170.11714146720twentyfifteen_scripts( '' ).../class-wp-hook.php:341
180.14204274832wp_style_add_data( $handle = 'twentyfifteen-ie7', $key = 'conditional', $value = 'lt IE 8' ).../functions.php:444
190.14204274832WP_Styles->add_data( $handle = 'twentyfifteen-ie7', $key = 'conditional', $value = 'lt IE 8' ).../functions.wp-styles.php:245
200.14204274832WP_Dependencies->add_data( $handle = 'twentyfifteen-ie7', $key = 'conditional', $value = 'lt IE 8' ).../class-wp-styles.php:385
210.14204274832_deprecated_argument( $function_name = 'WP_Dependencies->add_data()', $version = '6.9.0', $message = 'IE conditional comments are ignored by all supported browsers.' ).../class-wp-dependencies.php:317
220.14204275152wp_trigger_error( $function_name = '', $message = 'Function WP_Dependencies->add_data() was called with an argument that is <strong>deprecated</strong> since version 6.9.0! IE conditional comments are ignored by all supported browsers.', $error_level = 16384 ).../functions.php:5925
230.14214275376trigger_error( $message = 'Function WP_Dependencies-&gt;add_data() was called with an argument that is <strong>deprecated</strong> since version 6.9.0! IE conditional comments are ignored by all supported browsers.', $error_level = 16384 ).../functions.php:6131

利用临时表,加快存储过程的执行速度。

利用临时表,加快存储过程的执行速度。


背景:
  一个博客网站访问流量表,每天有大约100万条数据插入,记录每个博客及网站的访问情况。表结构:
mysql> show fields from blog_track;
+—————-+————–+——+—–+———+—————-+
| Field          | Type         | Null | Key | Default | Extra          |
+—————-+————–+——+—–+———+—————-+
| track_id       | int(11)      | NO   | PRI | NULL    | auto_increment |
| track_ip       | char(15)     | YES  |     | NULL    |                |
| track_date     | datetime     | NO   | MUL |         |                |
| track_page     | varchar(256) | YES  |     | NULL    |                |
| track_refferer | varchar(500) | YES  |     | NULL    |                |
| member_id      | int(11)      | NO   | MUL | 0       |                |
| visiter_id     | int(11)      | NO   |     | 0       |                |
| track_type     | tinyint(4)   | NO   | MUL | 0       |                |
+—————-+————–+——+—–+———+—————-+



每隔2小时就会利用存储过程对这个表进行统计,包括统计当天的IP及PV。


CREATE DEFINER=`root`@`%` PROCEDURE `prc_anaylise_track`()
BEGIN


declare time_now datetime;
DROP TABLE IF EXISTS tmp_tables;
CREATE TEMPORARY TABLE tmp_tables (
blog_id int NOT NULL,
count int NOT NULL,
ip char(15) null
) engine = HEAP;
set time_now = now();
insert into tmp_tables(count,blog_id,ip) select count(*) as count,member_id as blog_id,track_ip as ip  from blog_track where track_type=0 and track_date>=date_format(now(),’%Y-%m-%d 00:00:00′) and member_id>0 group by track_ip,member_id;
update blog_info set blog_info.today_ip = (select count(*) as count from tmp_tables where blog_info.member_id=tmp_tables.blog_id);
delete from tmp_tables;
select concat(‘count today ip count need time : ‘,(unix_timestamp(now()) – unix_timestamp(time_now))) as neetTime;
END


使用了一个临时表保存统计结果,执行时间超过15秒。



下面是使用了两个临时表的代码:


CREATE DEFINER=`root`@`%` PROCEDURE `prc_anaylise_user`()
BEGIN


declare time_now datetime;
DROP TABLE IF EXISTS tmp_tables_full;
CREATE TEMPORARY TABLE tmp_tables_full (
blog_id int not null,
count int not null default 0,
ip char(15) null,
index blog_id(blog_id)
)engine = HEAP;


DROP TABLE IF EXISTS tmp_tables;
CREATE TEMPORARY TABLE tmp_tables (
blog_id int NOT NULL,
count int NOT NULL,
ip char(15) null,
index blog_id(blog_id)
) engine = HEAP;


set time_now = now();
insert into tmp_tables_full(blog_id,ip) select member_id,track_ip  from blog_track where track_type=0 and track_date>=date_format(now(),’%Y-%m-%d 00:00:00′) and member_id>0;
insert into tmp_tables(count,blog_id,ip) select count(*) as count,blog_id,ip  from tmp_tables_full group by blog_id,ip;
update blog_info set blog_info.today_ip = (select count(*) as count from tmp_tables where blog_info.member_id=tmp_tables.blog_id);
delete from tmp_tables_full;
delete from tmp_tables;
select concat(‘count today ip count need time : ‘,(unix_timestamp(now()) – unix_timestamp(time_now))) as neetTime;
END


第一个临时表存放今天的访问记录,第一个临时表存放统计结果。这样做的目的是避免统计时间过长,锁表时间过长,导致网站访问不正常。执行时间为2秒。



进一步优化:
定义一个临时变量,
declare p_updatetime datetime;
建立一个tmpupdatetable表,保存上一次执行的时间;
select updatetime into p_updatetime from tmpupdatetable;
把最后执行的时间回到where条件里:
insert into tmp_tables_full(blog_id,ip) select member_id,track_ip  from blog_track where track_type=0 and track_date>=date_format(now(),’%Y-%m-%d 00:00:00′)  and track_date>=p_updatetime and member_id>0;
更新数据时的代码:
update blog_info set blog_info.today_ip =blog_info.today_ip+ (select count(*) as count from tmp_tables where blog_info.member_id=tmp_tables.blog_id);



经过样的修改,执行时间变了120ms左右。已经符合要求了,如果没有达到这个效果的话,请检查一个blog_track表的索引。


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.