以下是我面试遇到的几个问题,很难自己解决,请各位大侠帮忙下
Sql 性能问题
T_plan表和t_plan_detail表为主从关系表,靠plan_id外键关联(存在索引)。
其中t_plan 100万行记录,t_plan_detail 1000万行记录,t_plan_detail.item_code上有索引。
简述下面sql语句有什么性能问题
(1)select count(*) from t_plan_detail t1 left join t_plan t2 on t1.plan_id = t2.plan_id where
t2.item_code = ‘P004’
上面提示说两处性能问题
(2)select count(1) from t_plan whre plan_id in(
Select plan_id from t_plan_detail where item_code =’p004’
) and plan status in(4,60)
(3)
Select plan_code , plan_status , create_date –create_date是t_plan_detail 的字段
From (select a.create_userid ,a.plan_code ,a..plan_status ,b*
From t_plan a ,t_plan_detail b
Where a.plan_id = b.plan_id
And b.item_code =’p004’
Order by b.create_date , a.plan_code
) X
Where x.create_userid = 1 order by x..plan_code desc
上面提示有三个性能问题
(4)
在某个数据表中有1000条记录,假设某状态字段有10个不同的值,且记录中状态的分布值会均等,那么按照该状态创建的索引的选择率是
A 10% B 50% C 90% D:100% E 都不对,请填写正确的值
库存明显帐invssummary表,存在下面一些字段
Columunname 字段含义
Year 年
Month 月
Plant 日
Productcode 产品编号
Productname 产品名称
Spec 规格
Warehouseid 仓库id
Warehousename 仓库名称
Amount 库存金额
现在抽取每个仓库每月的库存金额排名前3的产品资料 ,请给出sql语句
(5)某集团公司以及北京,南京和上海分公司使用某套企业管理系统,要求不同岗位的用户分别有不同的权限,比如主数据管理和业务操作权限等,如何实现这些不同岗位的用户之间的权限管理?请先假设需求场景,再用你最熟悉的建模语言来表达你的设计思想
这道题更是没头绪,请各位给点思想