mysql 多表join count数据很慢 5C

问题如题

SELECT
    COUNT(1)
FROM
    wf_workitem a -- 总数量159521
JOIN wf_activityinst b ON b.id = a.activityinst_id -- 总数量209453
JOIN wf_processinst c ON c.id = b.processinst_id  -- 总数量26307
WHERE
    a.operate_user = '7424'
AND a.current_state = 'AGREE'
AND c.comp_id = '4715C67AD2B0457A81D32CC0B1148840'
AND c.proj_id = ''

解析计划
图片说明

sql执行需要10s左右, 求给点优化建议

songwei1006
舍文 wf_workitem 的operate_user 和 current_state 两个列重复的值多吗?activityinst_id 这个外键上有没有索引?
一年多之前 回复

5个回答

你把join on 的字段加上索引,会快很多、或者新建个视图

最好的方式就是写存储过程,最后单表查询

看上去索引是ok的,这数据量要10秒,有点夸张.

关联字段加上索引 查询条件看看是不是高选择行 按照最左原则建立索引 还要考虑整个表是查询多还是修改删除多 不能光考虑查询问题

先按条件查出来数据然后再关联试下,例如:


SELECT COUNT(1)
  FROM (select *
          FROM wf_workitem a
         WHERE a.operate_user = '7424'
           AND a.current_state = 'AGREE') a
  JOIN wf_activityinst b
    ON b.id = a.activityinst_id
  JOIN (select *
          from wf_processinst c
         where c.comp_id = '4715C67AD2B0457A81D32CC0B1148840'
           AND c.proj_id = '') c
    ON c.id = b.processinst_id
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
mysql查询性能优化(数据量非常小,但查询很慢,初步确认是因为使用了左外连接)

首先,是这么一段sql: <br/> <font color="red">**SQL 1:**</font> <br/> ``` sql SELECT d.id, d.project_code, d.push_type, d.push_name, d.push_to, d.push_from, d.push_way, tr.isread, d.push_content, d.push_attachment, d.add_time, d.push_status, d.push_reviewer, push_time, d.reviewer_time, d.push_class, d.rel_object, p.short_name AS project_name, u1. NAME AS push_to_name, u2. NAME AS push_from_name, u3. NAME AS push_reviewer_name FROM tb_push_data d LEFT JOIN tb_project p ON p.short_code = d.project_code LEFT JOIN tb_user u1 ON u1. CODE = d.push_to LEFT JOIN tb_user u2 ON u2. CODE = d.push_from LEFT JOIN tb_user u3 ON u3. CODE = d.push_reviewer LEFT JOIN tb_push_log tr ON tr.pushdata_id = d.id WHERE 1 = 1 AND d.add_time BETWEEN '2017-01-01' and '2018-01-11' GROUP BY d.id LIMIT 0,100 受影响的行: 0 时间: 24.933s ``` <br/> 可以看到,仅仅是100条数据,查询时间竟然高达24秒,于是我尝试将左外连接改为交叉连接: <br/> <font color="red">**SQL 2:**</font> ``` sql SELECT d.id, d.project_code, d.push_type, d.push_name, d.push_to, d.push_from, d.push_way, tr.isread, d.push_content, d.push_attachment, d.add_time, d.push_status, d.push_reviewer, push_time, d.reviewer_time, d.push_class, d.rel_object, p.short_name AS project_name, u1. NAME AS push_to_name, u2. NAME AS push_from_name, u3. NAME AS push_reviewer_name FROM tb_push_data d, tb_project p, tb_user u1, tb_user u2, tb_user u3, tb_push_log tr WHERE 1 = 1 and p.short_code = d.project_code and u1. CODE = d.push_to and u2. CODE = d.push_from and u3. CODE = d.push_reviewer and tr.pushdata_id = d.id AND d.add_time BETWEEN '2017-01-01' and '2018-01-11' GROUP BY d.id LIMIT 0,100 受影响的行: 0 时间: 0.189s ``` <br/> 这一下查询时间终于算是正常了,看来很多人说的数据库查询不用外键不用join还是有道理的。 但是这又出现了一个问题,<font color="red">**因为SQL 2没有使用外连接,比如我某条数据是没有推送人的,那这条记录都显示不出来了。**</font> <br/> 那么,针对目前的这种情况,该如何优化?

mysql 视图 left join 非常慢

select uuid() AS `myid`,`tu`.`id` AS `id`,`tu`.`job_number` AS `job_number`,`tu`.`email` AS `useremail`,`tu`.`name` AS `name`,`tu`.`dept` AS `dept`,`tu`.`manger` AS `manger`,`tu`.`status` AS `status`,`tu`.`createDate` AS `createDate`,`tu`.`updateDate` AS `updateDate`,`tchk`.`name` AS `sysName`,`tchk`.`number` AS `sysNumber`,`tchk`.`status` AS `sysStatus`,`tchk`.`createDate` AS `sysCreateDate`,'香港集群账号' AS `tableName` from (`tiw_user` `tu` left OUTER join `tiw_clusterHkNum` `tchk` on((`tchk`.`tiwUid` = `tu`.`id`))) where 1 = 1 union all select uuid() AS `myid`,`tu`.`id` AS `id`,`tu`.`job_number` AS `job_number`,`tu`.`email` AS `useremail`,`tu`.`name` AS `name`,`tu`.`dept` AS `dept`,`tu`.`manger` AS `manger`,`tu`.`status` AS `status`,`tu`.`createDate` AS `createDate`,`tu`.`updateDate` AS `updateDate`,`tcsz`.`name` AS `sysName`,`tcsz`.`number` AS `sysNumber`,`tcsz`.`status` AS `sysStatus`,`tcsz`.`createDate` AS `sysCreateDate`,'深圳集群账号' AS `tableName` from (`tiw_user` `tu` left OUTER join `tiw_clusterSzNum` `tcsz` on((`tcsz`.`tiwUid` = `tu`.`id`))) where 1 = 1 union all select uuid() AS `myid`,`tu`.`id` AS `id`,`tu`.`job_number` AS `job_number`,`tu`.`email` AS `useremail`,`tu`.`name` AS `name`,`tu`.`dept` AS `dept`,`tu`.`manger` AS `manger`,`tu`.`status` AS `status`,`tu`.`createDate` AS `createDate`,`tu`.`updateDate` AS `updateDate`,`tcwh`.`name` AS `sysName`,`tcwh`.`number` AS `sysNumber`,`tcwh`.`status` AS `sysStatus`,`tcwh`.`createDate` AS `sysCreateDate`,'武汉集群账号' AS `tableName` from (`tiw_user` `tu` left OUTER join `tiw_clusterWhNum` `tcwh` on((`tcwh`.`tiwUid` = `tu`.`id`))) where 1 = 1 **说明:(一共用十表union进行连接 代码都是重复)且左右表的数据量相差比较大**

mysql count 优化问题

使用jdbcTemplate,做统一的分页查询的时候, count(*)在数据量大的时候,总数查询非常慢, 有什么好的解决方案, count(1)和count(*)就不要说了 也建了适当的索引, 使用结果集的游标直接指向最后能有效果么?

mysql left join效率优化

通过下面sql查询商品库存数量,因为库存表里面的库存是很多仓库的库存数据,在left join的时候又要做一个表连接,这样查询的时候效率非常低,如果left join一个表就很快,但是无法满足需求,请大神门帮忙优化下sql,谢谢 select g.*,gsd.number from goods g left join (select gs.goods_id,sum(gs.number) number from goods_stock gs,warehouses w where gs.warehouse_id=w.id group by gs.goods_id and w.id='123456789') gsw on(g.id=gsd.goods_id)

mysql两个单表都在30万数据的表联合查询,查询时间长,求优化

现在有两个表,每个表的数据量 30万左右 。表一的id和表2的res_id是关联的,因为表2和另一张表关联,所以无法做外键。 现在需求是 检索条件都在表一,但是排序是根据表二的字段排序。普通写法最后结果,都在5S以上速度太慢。求大神给出优化意见。刚才没有补充,on后面都是主键,where后面的都建立了普通索引,orderby 后面的也是普通索引。 sql 如下: ``` SELECT a.id, a.title, a.type, a.digest, a.file_type, a.file_sufix, a.bpackage, a.author_name, a.source, a.source_name, a.org_name, b.download_count, b.preview_count, b.favorite_count, a.author, a.section_name, a.subject_name, a.version_name, a.material_name, a.chapter_name, b.evaluate_count FROM res_resource a LEFT JOIN res_statistics b ON a.id = b.res_id WHERE a.dflag = 0 AND a.sflag = 1 AND a.publish_status = '1' ORDER BY overall_score DESC LIMIT 0,10 ``` 表1 ![表1](https://img-ask.csdn.net/upload/201804/09/1523259185_588613.png) <br/> 表2 ![表2](https://img-ask.csdn.net/upload/201804/09/1523259221_845390.png) <br/>

linq多表连接查询速度很慢,但我在数据库查询分析器中却是秒查,请各位大侠帮我分析下

1. with temp as ( select (case when SHIFTSCHEDULEID is null then (case when TICKET_SELL_TYPE=2 then (select COMPANY_ID from TBL_YD_SHIFT where SHIFTNUMBER= (select SHIFTNUMBER from TBL_SP_TICKET where ticketid=a.REFUND_TICKET_ID)) else (select deptid from tbl_xt_user where userid=a.userid) end) else b.company_id end ) as deptid, a.userid,a.DAY, SELL_DATE,SELL_WAY,a.SHIFTNUMBER,ticketid,ticket_type,TICKET_STATE,TICKET_NO,IN_MONEY,out_money,REFUND_TICKET_ID from tbl_sp_ticket a left join TBL_YD_SHIFT b on a.SHIFTNUMBER=b.SHIFTNUMBER where TICKET_STATE not in(5,6) ) select a.ticket_no,a.shiftnumber,a.DAY,a.STARTTIME,(select username from TBL_XT_USER where userid=a.USERID)as username, (select sitename from TBL_YD_SITE where siteid=a.ENDSITE)as sitename, (case when (a.TICKET_STATE =2 and b.TICKET_NO is null)then '未检' when (a.TICKET_STATE =2 and b.jp_state=0 and c.LD_NO is null)then '已检' when (a.TICKET_STATE =2 and b.jp_state=1 )then '退检' when (a.TICKET_STATE =2 and b.jp_state=0 and c.LD_NO is not null)then '已打路单' when a.TICKET_STATE =3 then '已退' when a.TICKET_STATE =5 then '破损' when a.TICKET_STATE =6 then '已废'end)as TicketState, (case a.TICKET_TYPE when 0 then '全票'when 1 then '半票'when 3 then'后付证'when 4 then '会员票' when 5 then '团体票'when 6 then '包车票'else '其它'end) as TicketType, a.IN_MONEY as priceJe,a.OUT_MONEY, isnull(c.ld_no,'')as Ld_No, a.SELL_DATE ,a.REFUND_TICKET_ID from tbl_sp_ticket a left join TBL_BB_JP b on a.TICKET_NO=b.TICKET_NO left join TBL_BB_WAYBILL c on b.LD_ID=c.ID 这是数据库中的查询代码; 2. public List<SpTicketRecordMx> GetSpRecordMxInfo(int deptid, DateTime startRq, DateTime endRq) { List<SpTicketRecordMx> list = new List<SpTicketRecordMx>(); using (var dbContext = new SKJTDBContext()) { var spUsers = from u in dbContext.Set<User>() select new { userid = u.USERID, username = u.USERNAME, usercode = u.USERCODE, deptid = u.DEPTID, zwgsid=u.USERUNIT }; var tempusers = spUsers.Where(u => u.zwgsid == deptid); //查询只属于指定站务公司下卖出的车票记录,通过班次号关联班次档案信息来判断 var shifts = dbContext.Set<Shift>().Where(s => s.COMPANY_ID == deptid); if (shifts == null || shifts.Count() == 0) return null; var spRecords = (from sp in dbContext.Set<Sp_Ticket>().Where( s => s.SELL_DATE <= endRq && s.SELL_DATE >= startRq).Where( s => !string.IsNullOrEmpty(s.SHIFTNUMBER)) join shift in shifts on sp.SHIFTNUMBER equals shift.SHIFTNUMBER select sp).ToList(); if (spRecords == null || spRecords.Count() == 0) return null; var nullshiftRecords = dbContext.Set<Sp_Ticket>().Where( s => s.SELL_DATE <= endRq && s.SELL_DATE >= startRq).Where( s => string.IsNullOrEmpty(s.SHIFTNUMBER)).ToList(); //单独处理班次号为空的情况 if (nullshiftRecords != null || nullshiftRecords.Count() > 0) { foreach (var sp in nullshiftRecords) { if (sp.TICKET_SELL_TYPE == TICKET_SELL_TYPE.退票) { var tempshift = dbContext.Set<Sp_Ticket>().Where( r => r.TICKETID == sp.REFUND_TICKET_ID).FirstOrDefault().SHIFTNUMBER; if (shifts.Any(s => s.SHIFTNUMBER == tempshift)) spRecords.Add(sp); else continue; } else { if (tempusers.Any(r => r.userid == sp.USERID)) spRecords.Add(sp); else continue; } } } var results = from t in spRecords join jp in dbContext.Set<Bb_Jp>().Where(w => w.OPER_TIME > startRq) on t.TICKETID equals jp.TICKETID into results1 from t_jp in results1.DefaultIfEmpty() join ld in dbContext.Set<Bb_Waybill>().Where(w => w.OPER_TIME > startRq) on t_jp == null ? new Bb_Jp().LD_ID : t_jp.LD_ID equals ld.ID into results2 from t_jp_ld in results2.DefaultIfEmpty() select new SpTicketRecordMx { TicketNO = t.TICKET_NO == null ? string.Empty : t.TICKET_NO, ShiftNumber = t.SHIFTNUMBER == null ? string.Empty : t.SHIFTNUMBER, StartRq = t.STARTTIME, time = t.STARTTIME == null ? string.Empty : ((DateTime)t.STARTTIME).ToString("t"), TicketState = t_jp == null ? t.TICKET_STATE.ToString() : (t_jp.JP_STATE == JP_STATE.已检 ? (t_jp.LD_ID == null ? "已检未打路单" : "已打路单") :(t.TICKET_STATE==TICKET_STATE.已退? "已退": "退检")), EndSite = t.ENDSITE == null ? string.Empty : dbContext.Set<Site>().Where( s => s.SITEID == t.ENDSITE).FirstOrDefault().SITENAME, PriceJe = t.IN_MONEY, Out_Money = t.OUT_MONEY, RefoundTicketID = t.REFUND_TICKET_ID, Ld_No = t_jp_ld == null ? string.Empty : t_jp_ld.LD_NO, TicketType = t.TICKET_SELL_TYPE.ToString(), UserName = spUsers.Where(u => u.userid == t.USERID).FirstOrDefault() == null ? "SPYA" : spUsers.Where(u => u.userid == t.USERID).FirstOrDefault().username, OperateRq = (DateTime)t.SELL_DATE }; // var liettemp = results.ToList(); return results.ToList(); } } 这是c#写的代码,这代码运行时查询得20多秒,请问各位好心的大婶这段代码怎么优化,小弟感激不敬!新手求各位大婶指点!

请教存储过程执行很慢,如何优化?

BEGIN DECLARE personPlaneId BIGINT; DECLARE starttime datetime; #开始时间 DECLARE endtime datetime; #结束时间 DECLARE sumStudyTime INT; #当前学时 DECLARE targetStudyTime INT; #目标学时 DECLARE id1_count BIGINT default 0; #t_stage_info 第一阶段count DECLARE id2_count BIGINT default 0; #t_stage_info 第二阶段count DECLARE id3_count BIGINT default 0; #t_stage_info 第三阶段count DECLARE firstEndTime datetime; #第一阶段结束时间 DECLARE secEndTime datetime; #第二阶段结束时间 DECLARE thirdEndTime datetime; #第三阶段结束时间 DECLARE done INT DEFAULT 0; #声明光标 DECLARE cur1 CURSOR FOR SELECT p1.id, p1.start_learn_time start_time, p1.last_date end_time, p1.sum_study_time,p1.target_study_time FROM t_person_plan p1 LEFT JOIN t_person_plan_record p2 ON p1.id = p2.person_plan_id WHERE p1.license_type = 7 AND p1.last_date <= CURRENT_DATE(); #t_person_plan_record p2 这个表数据大概500多万条 #当游标到达尾部时,mysql自动设置done=1 declare continue handler for SQLSTATE '02000' SET done = 1; OPEN cur1; REPEAT /* 移动游标并赋值 */ fetch cur1 into personPlaneId,startTime,endTime,sumStudyTime,targetStudyTime; if NOT done then #获取第一阶段结束时间 SET firstEndTime = (SELECT add_time FROM t_person_plan_record WHERE person_plan_id=personPlaneId AND chapter_id=29611); #获取第二阶段结束时间 SET secEndTime = (SELECT add_time FROM t_person_plan_record WHERE person_plan_id=personPlaneId AND chapter_id=29625); #获取第三阶段结束时间 SET thirdEndTime = (SELECT add_time FROM t_person_plan_record WHERE person_plan_id=personPlaneId AND chapter_id=29734); #获取主键标识 SELECT count(1) into id1_count from t_stage_info where person_plan_id=personPlaneId AND stage=1; SELECT count(1) into id2_count from t_stage_info where person_plan_id=personPlaneId AND stage=2; SELECT count(1) into id3_count from t_stage_info where person_plan_id=personPlaneId AND stage=3; IF sumStudyTime <= 12 THEN IF id1_count=0 THEN INSERT INTO t_stage_info(person_plan_id,start_time,end_time,sum_study_time,target_study_time,stage) VALUES(personPlaneId,startTime,endTime,sumStudyTime,targetStudyTime,1); ELSE UPDATE t_stage_info SET end_time=endTime,sum_study_time=sumStudyTime WHERE person_plan_id=personPlaneId AND stage=1; END IF; #当学到第二阶段时 ELSEIF sumStudyTime>12 AND sumStudyTime<=14 THEN #更新第一阶段数据 IF id1_count=0 THEN INSERT INTO t_stage_info(person_plan_id,start_time,end_time,sum_study_time,target_study_time,stage) VALUES(personPlaneId,startTime,firstEndTime,sumStudyTime,targetStudyTime,1); ELSE UPDATE t_stage_info SET end_time=firstEndTime,sum_study_time=sumStudyTime WHERE person_plan_id=personPlaneId AND stage=1; END IF; #更新第二阶段数据 IF id2_count=0 THEN INSERT INTO t_stage_info(person_plan_id,start_time,end_time,sum_study_time,target_study_time,stage) VALUES(personPlaneId,firstEndTime,endTime,sumStudyTime,targetStudyTime,2); ELSE UPDATE t_stage_info SET end_time=endTime,sum_study_time=sumStudyTime WHERE person_plan_id=personPlaneId AND stage=2; END IF; #当学到第三阶段时 ELSEIF sumStudyTime>14 THEN #如果thirdEndTime为空则取最后学习的时间 SET thirdEndTime = CASE WHEN thirdEndTime IS NULL THEN endTime ELSE thirdEndTime END; #更新第一阶段数据 IF id1_count=0 THEN INSERT INTO t_stage_info(person_plan_id,start_time,end_time,sum_study_time,target_study_time,stage) VALUES(personPlaneId,startTime,firstEndTime,sumStudyTime,targetStudyTime,1); ELSE UPDATE t_stage_info SET end_time=firstEndTime,sum_study_time=sumStudyTime WHERE person_plan_id=personPlaneId AND stage=1; END IF; #更新第二阶段数据 IF id2_count=0 THEN INSERT INTO t_stage_info(person_plan_id,start_time,end_time,sum_study_time,target_study_time,stage) VALUES(personPlaneId,firstEndTime,secEndTime,sumStudyTime,targetStudyTime,2); ELSE UPDATE t_stage_info SET end_time=secEndTime,sum_study_time=sumStudyTime WHERE person_plan_id=personPlaneId AND stage=2; END IF; #更新第三阶段数据 IF id3_count=0 THEN INSERT INTO t_stage_info(person_plan_id,start_time,end_time,sum_study_time,target_study_time,stage) VALUES(personPlaneId,secEndTime,thirdEndTime,sumStudyTime,targetStudyTime,3); ELSE UPDATE t_stage_info SET end_time=thirdEndTime,sum_study_time=sumStudyTime WHERE person_plan_id=personPlaneId AND stage=3; END IF; END IF; end if; UNTIL done END REPEAT; close cur1; END 现在执行了2小时才有了10几万数据, 我在t_person_plan_record 表里对‘person_plan_id ’建了索引, 在表t_stage_info 对person_plan_id ’建立了索引,其他我就不知道怎么优化了, 请问大神,还能怎么优化比较好呢?

mysql查询速度慢???????

小弟这里有一个SQL查询非常慢,大佬看一下有没有什么办法能优化一下? 各个表的数据量分别为 ic_file_proc_state ps; 3700000 og_file_audit ps; 300000 ic_file_audit ps; 2800008 SELECT ps.ic_file_nm, ps.BIZ_LINE, ps.DB_INSR_TM, ps.state, ps.cdr_count, fa.cdr_count fa_cdr_count, fa.ic_file_chg_intax fa_ic_file_chg_intax, fa.tap_format fa_tap_format, oa.rec_count oa_rec_count, oa.chg_intax oa_chg_intax, oa.tap_format oa_tap_format FROM (SELECT ps.ic_file_nm, ps.BIZ_LINE, ps.DB_INSR_TM, ps.state, ps.cdr_count FROM ic_file_proc_state ps) ps LEFT JOIN ic_file_audit fa ON ps.ic_file_nm = fa.ic_file_nm LEFT JOIN og_file_audit oa ON ps.ic_file_nm = oa.OG_FILE_NM WHERE ps.state IN (1, 2, 3, 4)

从视图查询在mysql中非常慢

<div class="post-text" itemprop="text"> <p>I have two tables. (1) <code>ENQUIRY</code> , (2) <code>FOLLOW_UP</code> . I have to store data from <code>FOLLOW_UP</code> against <code>MAX(VISITOR_ID)</code> in a view. My view is created successfully and I can view data in <code>phpMyadmin</code>.</p> <p>(1) <code>ENQUIRY</code> TABLE</p> <pre><code>$enq = " CREATE TABLE IF NOT EXISTS ENQUIRY ( ID BIGINT PRIMARY KEY AUTO_INCREMENT , LONGDATE BIGINT, UNAME VARCHAR(200) , ADDRESS VARCHAR(200) , STATE VARCHAR(60) , ZIP VARCHAR(20) , PHONE VARCHAR(100) , AGE INTEGER , SEX VARCHAR(6) , DOB_DATE INTEGER , DOB_MONTH INTEGER , DOB_YEAR INTEGER , MARITAL_STATUS VARCHAR(30), BLOOD_GROUP VARCHAR(10), EMAIL VARCHAR(200), IS_MEMBER VARCHAR(3) DEFAULT 'NO' , REF_SOURCE VARCHAR(150) , REFERENCE VARCHAR(150), LAST_FOLLOWUP BIGINT DEFAULT 0, CREATE_BY VARCHAR(100), CREATE_ON BIGINT, SERVER INTEGER DEFAULT 0)"; </code></pre> <p>(2) <code>FOLLOW_UP</code> TABLE</p> <pre><code>$enq = " CREATE TABLE IF NOT EXISTS FOLLOW_UP ( ID BIGINT PRIMARY KEY AUTO_INCREMENT , VISITOR_ID BIGINT , VISITOR_NAME VARCHAR(200) , LONGDATE BIGINT , FEED_BACK VARCHAR(200) , NEXT_CONTACT BIGINT , FEED_BACK_SUMMARY VARCHAR(80) , FOLLOWUP_BY VARCHAR(80), SERVER INTEGER DEFAULT 0)"; </code></pre> <p>My view is as follows:</p> <pre><code>$enq = "CREATE OR REPLACE VIEW F_TOFOLLOW AS SELECT FOLLOW_UP.ID, FOLLOW_UP.LONGDATE, FOLLOW_UP.VISITOR_ID, ENQUIRY.UNAME, FOLLOW_UP.FEED_BACK, FOLLOW_UP.FEED_BACK_SUMMARY, FOLLOW_UP.FOLLOWUP_BY, FOLLOW_UP.NEXT_CONTACT, ENQUIRY.CREATE_BY, ENQUIRY.IS_MEMBER FROM FOLLOW_UP INNER JOIN ENQUIRY ON FOLLOW_UP.VISITOR_ID = ENQUIRY.ID WHERE FOLLOW_UP.ID = (SELECT MAX(ID) FROM FOLLOW_UP F WHERE F.VISITOR_ID = FOLLOW_UP.VISITOR_ID)"; </code></pre> <p>Now I am trying to run query from the view:</p> <pre><code>$Q = "SELECT COUNT(*) AS TOFOLLOW FROM F_TOFOLLOW"; </code></pre> <p>Any Query I try to execute is very very very very slow. Even most of the time I get:</p> <blockquote> <p>SQLSTATE[HY000]: General error: 2006 MySQL server has gone away</p> </blockquote> <p>Some suggests me to update <code>max_allowed_packet</code> in mysql config but there is no way to do so in a shared hosting.</p> <p>Similar views are running fine. What is wrong with my code? Is there any way to resolve this issue?</p> </div>

日志流水表应该怎么建索引?

MYSQL 数据库 有一个消息日志 MESSAGELOG 表,系统每隔2秒会向里面插入大概10条记录 现在这个表里面有30万条记录 有 id,time,label_id,tower_id,station_id 5个字段,id是主键 这个表的特点是 label_id,tower_id,station_id的重复非常多, 很多记录不同的地方就是时间time 不一样(当然还有id不一样) 比如label_id=226的记录有27216条,这个 27216 条记录的 label_id,tower_id,station_id都一样,就time不一样 这个查询: select count(1) from MESSAGELOG log LEFT join LABEL label on log.label_id = label.binary_id LEFT join DEVICE tower on log.tower_id = tower.binary_id LEFT join DEVICE station on log.station_id = station.binary_id where tower.type in ('TYPE_ONEWAYTOWER','TYPE_ALLWAYTOWER') and station.type = 'TYPE_STATION' 需要4秒。 MESSAGELOG 表 time,label_id,tower_id,station_id有索引,还有一个(label_id,tower_id,station_id)联合索引 MESSAGELOG 30万记录,LABEL 表20条记录,DEVICE 24条记录 上面的查询要用4秒,属于正常,还是慢? 索引设计的合理么,该怎么设计? 另外,这个日志表的数据会越来越多,对于300万,500万,乃至1000万的数据量,继续用MYSQL合适么? 希望有经验的朋友说说。

mssql 视图语句优化 很慢

这个视图只要count(1)就很慢,同时CPU也会很高,需要怎么样来写会快些 ALTER VIEW [dbo].[V_SynthesizeAsyn] AS SELECT a.Sysnumber , a.OrderId , a.OrderTime , a.MemberId , a.AvType , a.AvObject , a.AvDescription , CASE a.AvObject WHEN 'gs' THEN '金牌供应商' WHEN 'etp' THEN '企业诚信通' WHEN 'itp' THEN '海外TP' WHEN 'zg' THEN '中供' ELSE a.AvObject END AS AvObjectCn , a.CompanyNameCn , a.MemberNameCn , a.DangerDetail , a.IfRenew , CASE a.IfRenew WHEN 'y' THEN '是' ELSE '否' END AS IfRenewCn , b.WarningGrade , d.CompanyProvince , d.CompanyProvince AS Province , d.CompanyCity , d.CompanyCity AS city , rs.Name AS CompanyCityCN , Ps.Name AS CompanyProvinceCN , b.CurrentNodeID , b.CurrentNodeName , b.IfProveCheck , b.IfBusiCheck , b.IfRenew_Again , CASE b.IfRenew_Again WHEN 'y' THEN '是' ELSE '否' END AS IfRenew_AgainCn , b.IsFeedBack , CASE b.IsFeedBack WHEN '1' THEN '是' ELSE '否' END AS IsFeedBackCn , b.FeedBackTime , e.Operator , d.CompanyName , e.OperatorName , d.CeoName , d.Tel , f.Result , ( CASE UPPER(ISNULL(f.Result, '')) WHEN 'YES' THEN '完全正确' WHEN 'NO' THEN '完全不正确' WHEN 'OTHER' THEN '部分正确' ELSE '' END ) AS Result_Name , b.ErrorDot , a.MakerID , a.Maker , d.CompanyAddr , d.LicenseNumber , b.IfTranslate , b.TranslateAudit , f.Content , d.CompanyEntityType , z.Name AS EntityTypeName , y.USERNAME , x.Maker AS LastVerify , a.VeriScope , a.ExpireDate , a.Priority FROM dbo.T_SendAVInfo AS a WITH ( NOLOCK ) INNER JOIN dbo.T_OrderStateInfo AS b WITH ( NOLOCK ) ON a.Sysnumber = b.SendAVInfoSysnumber AND b.IfRemove = '0' LEFT JOIN dbo.T_DataCollectInfo AS d WITH ( NOLOCK ) ON a.Sysnumber = d.SendAVInfoSysnumber LEFT JOIN dbo.T_DataDispense AS e WITH ( NOLOCK ) ON e.OperateState = '1' AND a.Sysnumber = e.SendAVInfoSysnumber LEFT JOIN dbo.T_SideVerifyRecords AS f WITH ( NOLOCK ) ON a.Sysnumber = f.SendAVInfoSysnumber LEFT JOIN ( SELECT Name , Number FROM dbo.Base_DDTree WITH ( NOLOCK ) WHERE ( PareNumber = 'ST0906100004' ) ) AS z ON z.Number = d.CompanyEntityType LEFT JOIN ( ( SELECT Name , Number FROM dbo.Base_DDTree WHERE DataType = 'hzst_tree_area' AND DELETEED = '0' AND IfLeaf = 0 ) ) AS rs ON rs.Number = d.CompanyCity LEFT JOIN ( ( SELECT Name , Number FROM dbo.Base_DDTree WHERE DataType = 'hzst_tree_area' AND DELETEED = '0' ) ) AS Ps ON Ps.Number = d.CompanyProvince LEFT JOIN ( SELECT USERID , USERNAME FROM dbo.T_IA_USERS WITH ( NOLOCK ) ) AS y ON e.Operator = y.USERID --获取审核人 LEFT JOIN ( SELECT loga.SendAVInfoSysnumber , logb.Maker FROM ( SELECT SendAVInfoSysnumber , MAX(CreateTime) AS CreateTime FROM dbo.T_Operationlog WITH ( NOLOCK ) WHERE CurrentNodeID = '111' AND T_Operationlog.SendAVInfoSysnumber='111' GROUP BY SendAVInfoSysnumber ) loga LEFT JOIN ( SELECT SendAVInfoSysnumber , CreateTime , Maker , CurrentNodeID FROM dbo.T_Operationlog WITH ( NOLOCK ) ) logb ON loga.SendAVInfoSysnumber = logb.SendAVInfoSysnumber AND loga.CreateTime = logb.CreateTime ) x ON a.Sysnumber = x.SendAVInfoSysnumber; LEFT JOIN ( SELECT TOP 1 SendAVInfoSysnumber , Maker FROM T_Operationlog ORDER BY CreateTime DESC ) x ON a.Sysnumber = x.SendAVInfoSysnumber; GO SQL Server 分析和编译时间: CPU 时间 = 3656 毫秒,占用时间 = 3691 毫秒。 (1 行受影响) 表 'Base_DDTree'。扫描计数 19,逻辑读取 22 次,物理读取 0 次,预读 0 次,lob 逻辑读取 0 次,lob 物理读取 0 次,lob 预读 0 次。 表 'T_OrderStateInfo'。扫描计数 9,逻辑读取 6138 次,物理读取 0 次,预读 0 次,lob 逻辑读取 0 次,lob 物理读取 0 次,lob 预读 0 次。 表 'T_SendAVInfo'。扫描计数 9,逻辑读取 4747 次,物理读取 0 次,预读 0 次,lob 逻辑读取 0 次,lob 物理读取 0 次,lob 预读 0 次。 表 'T_DataCollectInfo'。扫描计数 9,逻辑读取 24325 次,物理读取 0 次,预读 0 次,lob 逻辑读取 0 次,lob 物理读取 0 次,lob 预读 0 次。 表 'Worktable'。扫描计数 0,逻辑读取 0 次,物理读取 0 次,预读 0 次,lob 逻辑读取 0 次,lob 物理读取 0 次,lob 预读 0 次。 表 'T_DataDispense'。扫描计数 9,逻辑读取 5456 次,物理读取 0 次,预读 0 次,lob 逻辑读取 0 次,lob 物理读取 0 次,lob 预读 0 次。 表 'T_SideVerifyRecords'。扫描计数 9,逻辑读取 5960 次,物理读取 0 次,预读 0 次,lob 逻辑读取 0 次,lob 物理读取 0 次,lob 预读 0 次。 表 'Worktable'。扫描计数 0,逻辑读取 0 次,物理读取 0 次,预读 0 次,lob 逻辑读取 0 次,lob 物理读取 0 次,lob 预读 0 次。 SQL Server 执行时间: CPU 时间 = 25026 毫秒,占用时间 = 3613 毫秒。

Laravel orWhere()/ MySQL或查询需要很长时间

<div class="post-text" itemprop="text"> <p>I'm using Laravel 4.2 and my application is used for tracking inventory across multiple locations.</p> <p>The database is set up with an <code>inventory_items</code> table, <code>inventory_locations</code> table and a pivot table between them <code>inventory_items_inventory_location</code>, which contains the quantity values whilst referencing both the inventory item and location the record belongs to.</p> <p>My query is to find inventory items that have any location quantity value more than or equal to 0. In Laravel I'm using a subquery and orWhere like so:</p> <pre><code>InventoryItem::whereHas('inventoryLocations', function($q) { $q-&gt;where('reserved', '&gt;=', 0) -&gt;orWhere('available', '&gt;=', 0) # slow -&gt;orWhere('inbound', '&gt;=', 0) # slow -&gt;orWhere('total', '&gt;=', 0); # slow })-&gt;toSql(); </code></pre> <p>Which gives the following SQL:</p> <pre><code>select * from `inventory_items` where `inventory_items`.`deleted_at` is null and ( select count(*) from `inventory_locations` inner join `inventory_item_inventory_location` on `inventory_locations`.`id` = `inventory_item_inventory_location`.`inventory_location_id` where `inventory_item_inventory_location`.`inventory_item_id` = `inventory_items`.`id` and `reserved` &gt;= ? or `available` &gt;= ? # slow or `inbound` &gt;= ? # slow or `total` &gt;= ? # slow ) &gt;= 1 </code></pre> <p>The problem is that with the <code>or</code> statements (marked in the code by <code>#slow</code>) the query time is up to 1s directly with Sequel Pro, more than 5s through my Laravel app (or through artisan tinker). Without these 'or' checks (i.e. just checking for one quantity type e.g. 'reserved') the query is &lt;100ms on Sequel Pro and similar on the app/tinker.</p> <p>I'm not sure why adding these extra 'or' checks adds so much time to the query. Any ideas how to make a more performant query?</p> </div>

mybatis存储过程中第二update执行速度很慢导致,最终在存储过程中没有执行,求解决方案

create procedure assignOrder(in userId BIGINT,in arrangBy BIGINT,in meg VARCHAR(1000),out count BIGINT) begin IF userId is not NULL and arrangBy is not NULL THEN UPDATE apply_flow as a set arrange_by = userId,remark=meg,response_by=userId where arrange_by=arrangBy and id in( select b.id from apply_base b where a.id=b.id and b.status_no=1 ); update queue_resume_conversion set deal_by=userId where is_archive=1 and id in ( select conversion_id from apply_base base LEFT JOIN apply_flow flow on base.id=flow.id and base.status_no=1 where arrange_by=arrangBy); set count=1; ELSE set count=0; end IF; SELECT count; END 第二个update太慢的缘故还是,什么缘故,反正存储过程执行结果,但是第二个update没有任何效果

今天遇到的关于SQL视图分页查询的效率问题的困惑,求解

今天在敲代码过程中发现SQL视图分页查询会特别慢但是只有200来条数据 当时写的查询方法如下 ``` private string GetExecuteMissionShowListExport(HttpContext context) { BaseUserInfo userInfo = (BaseUserInfo)context.Session[Common.SessionUserInfo]; int pageIndex = Convert.ToInt32(context.Request["pageIndex"]); int pageSize = Convert.ToInt32(context.Request["pageSize"]); string sZXBH = context.Request["sZXBH"]; string state = context.Request["state"]; string bDate = context.Request["bDate"]; string eDate = context.Request["eDate"]; string sXJRID = context.Request["sXJRID"]; int recordCount = 0; StringBuilder sb = new StringBuilder(); sb.AppendFormat(" sXJBMID='{0}'", userInfo.OrgID); if (!string.IsNullOrEmpty(sZXBH)) { sb.AppendFormat(" AND sZXBH LIKE'%{0}%' ", sZXBH); } if (!string.IsNullOrEmpty(state)) { sb.AppendFormat(" AND iZT={0} ", state); } if (!string.IsNullOrEmpty(sXJRID)) { sb.AppendFormat(" AND sXJRID={0} ", sXJRID); } if (!string.IsNullOrEmpty(bDate) && string.IsNullOrEmpty(eDate)) { sb.AppendFormat(" And dJHXJSJ >= '{0} 00:00:00'", Convert.ToDateTime(bDate).ToString("yyyy-MM-dd")); } else if (string.IsNullOrEmpty(bDate) && !string.IsNullOrEmpty(eDate)) { sb.AppendFormat(" And dJHXJSJ < '{0} 23:59:59'", Convert.ToDateTime(eDate).ToString("yyyy-MM-dd")); } else if (!string.IsNullOrEmpty(bDate) && !string.IsNullOrEmpty(eDate)) { sb.AppendFormat(" And dJHXJSJ BETWEEN '{0} 00:00:00' and '{1} 23:59:59'", Convert.ToDateTime(bDate).ToString("yyyy-MM-dd"), Convert.ToDateTime(eDate).ToString("yyyy-MM-dd")); } string sqlStr = string.Format(@"SELECT * FROM ( SELECT ROW_NUMBER() OVER (ORDER BY sZXBH DESC) AS ROWID,* FROM ( SELECT A.*,B.sID FROM (SELECT sZXBH,sXJRXM,iZT,sXJBMID FROM V_XJ_ZXXMB ) A LEFT JOIN (SELECT sID,sZXBH FROM XJ_ZXB) B ON A.sZXBH=B.sZXBH )tb WHERE {0} )AS sp WHERE ROWID BETWEEN ({1}-1)*{2}+1 AND {1}*{2}", sb.ToString(), pageIndex, pageSize); System.Diagnostics.Debug.WriteLine(sqlStr); DataTable dt = new CommonBLL().Query(sqlStr); sqlStr = string.Format(@"SELECT sID FROM ( SELECT A.*,B.sID FROM (SELECT sZXBH,sXJRXM,iZT,sXJBMID FROM V_XJ_ZXXMB ) A LEFT JOIN (SELECT sID,sZXBH FROM XJ_ZXB) B ON A.sZXBH=B.sZXBH)tb WHERE {0}", sb.ToString()); System.Diagnostics.Debug.WriteLine(sqlStr); recordCount = new CommonBLL().Query(sqlStr).Rows.Count; return JsonClass.DataTableToJson(dt, recordCount); } ```

Json API的响应时间很慢

<div class="post-text" itemprop="text"> <p>We are using the JSON API plugin in which we are facing issue for the performance of the App.It takes a 10-20 seconds of the load time for the startup of the App.</p> <p>We tested the Api request and we got the result as some slow sql queries gets call as mentioned below.This query gets originating from the JSON API request.</p> <p>We are unable to identify from where does this sql query gets triggered as the path mentioned in the query we made some changes in post_type for example we excluded the post1 AND post2 from query.php but stiil no change we are getting the same result in slow sql query in database.</p> <pre><code>SELECT iqoyau1_posts.ID FROM iqoyau1_posts INNER JOIN iqoyau1_postmeta ON ( iqoyau1_posts.ID = iqoyau1_postmeta.post_id ) WHERE 1=1 AND ( ( iqoyau1_postmeta.meta_key = '_hide-in-ipad' AND CAST(iqoyau1_postmeta.meta_value AS CHAR) = '1' ) ) AND iqoyau1_posts.post_type IN ('post1', 'post2', 'post3', 'post4', 'post5) AND ((iqoyau1_posts.post_status = 'publish')) GROUP BY iqoyau1_posts.ID ORDER BY iqoyau1_posts.post_date DESC /* in [/plugins/ipad-app/query.php:38] </code></pre> <p>Here is our code of query.php:</p> <pre><code> &lt;?php function pre_get_posts( $wp_query ){ $json = $wp_query-&gt;get( 'json' ); if( !$json ) return $wp_query; $api_version = $wp_query-&gt;get( 'api_ver' ); if( version_compare($api_version, '2.0', '&lt;') ){ $wp_query-&gt;query_vars['post_type'] =array( 'ipad-post' ); $wp_query-&gt;query_vars['posts_per_page'] = 36; } elseif( version_compare($api_version, '2.0', '&gt;=') ){ $url = $_SERVER['REQUEST_URI']; if ($_GET["post_type"]== "XXX" &amp;&amp; strpos($url,'api_v2') ){ $wp_query-&gt;query_vars['post_type'] = 'XXX'; $wp_query-&gt;query_vars['posts_per_page'] = $_GET["count"]; }else{ $wp_query-&gt;query_vars['post_type'] = array( 'post3', 'post4','post5); $wp_query-&gt;query_vars['posts_per_page'] = $_GET["count"]; } // exclude posts set to not show in ipad app $not_in = new \WP_Query( array( 'fields' =&gt; 'ids', 'meta_key' =&gt; '_hide-in-ipad', 'meta_value' =&gt; 1, 'posts_per_page' =&gt; -1 ) ); $wp_query-&gt;query_vars['post__not_in'] = array_merge( $not_in-&gt;posts, $wp_query-&gt;get('post__not_in') ); } $wp_query-&gt;query_vars['ignore_sticky_posts'] = TRUE; return $wp_query; } add_filter( 'pre_get_posts', __NAMESPACE__.'\pre_get_posts' ); /* * allow post__not_in in query string with normal or json syntax * @param array * @return array */ function request( $qv ){ if( !empty($qv['api_ver']) &amp;&amp; version_compare($qv['api_ver'], '2.0', '&gt;=') &amp;&amp; !empty($_GET['post__not_in']) ){ if( is_string($_GET['post__not_in']) ) $qv['post__not_in'] = (array) json_decode( $_GET['post__not_in'] ); elseif( is_array($_GET['post__not_in']) ) $qv['post__not_in'] = $_GET['post__not_in']; $qv['post__not_in'] = array_map( 'intval', $qv['post__not_in'] ); } return $qv; } add_filter( 'request', __NAMESPACE__.' equest' ); </code></pre> <p>We have also optimized the attachments and tags from the json response the performance has improved little bit as before but still we are facing the performance issue from slow database query. How can we optimize the query Any Help.</p> </div>

递归函数对于创建分层选择列表来说太慢了

<div class="post-text" itemprop="text"> <p>I have a query that gets me a Geo-Structure from the database. </p> <p>Categories Table (30.000 rows inside):</p> <pre><code>id title parent type ------------------------------- 1 germany 0 1 2 bavaria 1 2 3 upper bavaria 2 3 4 munich 3 4 6 italy 0 1 7 toscana 6 2 8 city florence 7 3 9 florence 8 4 </code></pre> <p>Categories Language Table</p> <pre><code>cid language title -------------------------- 1 en-UK germany 2 de-DE deutschland </code></pre> <p>Objects table:</p> <pre><code>id title landid regionid uregionid cityid -------------------------------------------------- 1 o1 1 2 3 4 2 o2 1 2 3 4 3 o3 6 7 8 9 </code></pre> <p>MySQL query:</p> <pre><code>SELECT c.id, c.title, l.title AS translated, c.type, c.parent, count(c.id) as cnt FROM category c LEFT JOIN objects o ON (o.landid = c.id OR o.regionid = c.id OR o.uregionid = c.id OR o.cityid = c.id) LEFT JOIN category_lang l ON l.cid = c.id AND l.language = "en-UK" WHERE c.published = 1 AND o.published = 1 GROUP BY c.id ORDER BY c.parent </code></pre> <p>I get an associative array ($tree) with values like here:</p> <pre><code>Array ( [0] =&gt; Array ( [id] =&gt; 1 [title] =&gt; Germany [type] =&gt; 1 [parent] =&gt; 0 [cnt] =&gt; 1 ) [1] =&gt; Array ( [id] =&gt; 6 [title] =&gt; Italy [type] =&gt; 1 [parent] =&gt; 0 [cnt] =&gt; 1 ) [2] =&gt; Array ( [id] =&gt; 2 [title] =&gt; Bavaria [type] =&gt; 2 [parent] =&gt; 1 [cnt] =&gt; 1 ) [3] =&gt; Array ( [id] =&gt; 7 [title] =&gt; Toscana [type] =&gt; 2 [parent] =&gt; 6 [cnt] =&gt; 1 ) [4] =&gt; Array ( [id] =&gt; 3 [title] =&gt; Upper Bavaria [type] =&gt; 3 [parent] =&gt; 2 [cnt] =&gt; 1 ) [5] =&gt; Array ( [id] =&gt; 8 [title] =&gt; City Florence [type] =&gt; 3 [parent] =&gt; 7 [cnt] =&gt; 1 ) [6] =&gt; Array ( [id] =&gt; 4 [title] =&gt; Munich [type] =&gt; 4 [parent] =&gt; 3 [cnt] =&gt; 1 ) [7] =&gt; Array ( [id] =&gt; 9 [title] =&gt; Florence [type] =&gt; 4 [parent] =&gt; 8 [cnt] =&gt; 1 ) ) </code></pre> <p>Then i create a structure that will prepare the display of a select list:</p> <pre><code>public static function buildTree($tree, $root = 0) { $return = array(); foreach($tree as $child) { if($child['parent'] == $root) { $return[] = array( 'name' =&gt; $child, 'next' =&gt; self::buildTree($tree, $child['id']) ); } } return empty($return) ? null : $return; } </code></pre> <p>Then i send the structure inside $return to a function to create the final select list: </p> <pre><code>public static function buildSelect($tree, $s) { $option = ''; if(!is_null($tree) &amp;&amp; count($tree) &gt; 0) { foreach($tree as $node) { $selected = ''; $class_type = $node['name']['type']; $option .= '&lt;option value="'.$node['name']['id'].'" class="h'.$class_type.'" '.$selected.' data-type="'.$node['name']['type'].'"&gt;' .$node['name']['title']. ' (' . $node['name']['cnt'] . ')&lt;/option&gt;' . self::buildSelect($node['next'], $s); } return $option; } } </code></pre> <p>This all works but if the Geo-Structure gets really big the db query gets terrible slow. Would appreciate any ideas about how to speed this up, thanks!</p> </div>

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

String s = new String(" a ") 到底产生几个对象?

老生常谈的一个梗,到2020了还在争论,你们一天天的,哎哎哎,我不是针对你一个,我是说在座的各位都是人才! 上图红色的这3个箭头,对于通过new产生一个字符串(”宜春”)时,会先去常量池中查找是否已经有了”宜春”对象,如果没有则在常量池中创建一个此字符串对象,然后堆中再创建一个常量池中此”宜春”对象的拷贝对象。 也就是说准确答案是产生了一个或两个对象,如果常量池中原来没有 ”宜春” ,就是两个。...

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

Linux面试题(2020最新版)

文章目录Linux 概述什么是LinuxUnix和Linux有什么区别?什么是 Linux 内核?Linux的基本组件是什么?Linux 的体系结构BASH和DOS之间的基本区别是什么?Linux 开机启动过程?Linux系统缺省的运行级别?Linux 使用的进程间通信方式?Linux 有哪些系统日志文件?Linux系统安装多个桌面环境有帮助吗?什么是交换空间?什么是root帐户什么是LILO?什...

Linux命令学习神器!命令看不懂直接给你解释!

大家都知道,Linux 系统有非常多的命令,而且每个命令又有非常多的用法,想要全部记住所有命令的所有用法,恐怕是一件不可能完成的任务。 一般情况下,我们学习一个命令时,要么直接百度去搜索它的用法,要么就直接用 man 命令去查看守冗长的帮助手册。这两个都可以实现我们的目标,但有没有更简便的方式呢? 答案是必须有的!今天给大家推荐一款有趣而实用学习神器 — kmdr,让你解锁 Linux 学习新姿势...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

史上最全的 python 基础知识汇总篇,没有比这再全面的了,建议收藏

网友们有福了,小编终于把基础篇的内容全部涉略了一遍,这是一篇关于基础知识的汇总的文章,请朋友们收下,不用客气,不过文章篇幅肯能会有点长,耐心阅读吧爬虫(七十)多进程multiproces...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

85后蒋凡:28岁实现财务自由、34岁成为阿里万亿电商帝国双掌门,他的人生底层逻辑是什么?...

蒋凡是何许人也? 2017年12月27日,在入职4年时间里,蒋凡开挂般坐上了淘宝总裁位置。 为此,时任阿里CEO张勇在任命书中力赞: 蒋凡加入阿里,始终保持创业者的冲劲,有敏锐的...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

新一代神器STM32CubeMonitor介绍、下载、安装和使用教程

关注、星标公众号,不错过精彩内容作者:黄工公众号:strongerHuang最近ST官网悄悄新上线了一款比较强大的工具:STM32CubeMonitor V1.0.0。经过我研究和使用之...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

大学一路走来,学习互联网全靠这几个网站,最终拿下了一把offer

大佬原来都是这样炼成的

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

什么时候跳槽,为什么离职,你想好了么?

都是出来打工的,多为自己着想

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

你期望月薪4万,出门右拐,不送,这几个点,你也就是个初级的水平

先来看几个问题通过注解的方式注入依赖对象,介绍一下你知道的几种方式@Autowired和@Resource有何区别说一下@Autowired查找候选者的...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《经典算法案例》01-08:如何使用质数设计扫雷(Minesweeper)游戏

我们都玩过Windows操作系统中的经典游戏扫雷(Minesweeper),如果把质数当作一颗雷,那么,表格中红色的数字哪些是雷(质数)?您能找出多少个呢?文中用列表的方式罗列了10000以内的自然数、质数(素数),6的倍数等,方便大家观察质数的分布规律及特性,以便对算法求解有指导意义。另外,判断质数是初学算法,理解算法重要性的一个非常好的案例。

程序员必知的 89 个操作系统核心概念

操作系统(Operating System,OS):是管理计算机硬件与软件资源的系统软件,同时也是计算机系统的内核与基石。操作系统需要处理管理与配置内存、决定系统资源供需的优先次序、控制输入与输出设备、操作网络与管理文件系统等基本事务。操作系统也提供一个让用户与系统交互的操作界面。 shell:它是一个程序,可从键盘获取命令并将其提供给操作系统以执行。 在过去,它是类似 Unix 的系统上...

《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)

正确选择比瞎努力更重要!

立即提问
相关内容推荐