w-BIG TABLE-view+where-small table
w-BIG TABLE
DROP PROCEDURE IF EXISTS truncate_insert_sales_rank_toparow_month;
DELIMITER /w/
CREATE PROCEDURE truncate_insert_sales_rank_toparow_month ()
BEGIN
TRUNCATE sales_rank_toparow_month ;
INSERT INTO sales_rank_toparow_month (
fk_countrycode,
fk_categoryid,
history_year,
history_month
) SELECT
country,
categoryid,
grab_year,
grab_month
FROM
grab_sales_rank_month
GROUP BY
country,
categoryid,
grab_year,
grab_month ;
END/w/
DELIMITER;
CALL truncate_insert_sales_rank_toparow_month; DROP PROCEDURE IF EXISTS insert_update_sales_rank_toparow_month;
DELIMITER /w/
CREATE PROCEDURE insert_update_sales_rank_toparow_month ()
BEGIN
SET @wtab = ' sales_rank_toparow_month ';
SET @wtab_src = 'grab_sales_rank_month';
SET @w = 10;
SET @wyear_max=(SELECT MAX(grab_year) FROM grab_sales_rank_month)+1;
SET @wyear = (SELECT MIN(grab_year) FROM grab_sales_rank_month); WHILE @w < 101 DO
WHILE @wyear < @wyear_max DO
SET @wmonth=(SELECT MIN(grab_month) FROM grab_sales_rank_month WHERE grab_year=@wyear);
SET @wmonth_max=(SELECT MAX(grab_month) FROM grab_sales_rank_month WHERE grab_year=@wyear)+1;
WHILE @wmonth < @wmonth_max DO DROP VIEW IF EXISTS wview;
SET @wview_where = CONCAT(' WHERE grab_year=',@wyear,' AND grab_month=',@wmonth,' AND topx=',@w);
SET @wview = CONCAT('CREATE VIEW wview AS SELECT * FROM ',@wtab_src,@wview_where,';');
PREPARE stmt0 FROM @wview ;
EXECUTE stmt0 ;
DROP PREPARE stmt0; DROP VIEW IF EXISTS wview1;
SET @wview1_where = CONCAT(' WHERE history_year=',@wyear,' AND history_month=',@wmonth,';');
SET @wview1 = CONCAT('CREATE VIEW wview1 AS SELECT * FROM ',@wtab,@wview1_where,';');
PREPARE stmt2 FROM @wview1 ;
EXECUTE stmt2 ;
DROP PREPARE stmt2; SET @wfield = CONCAT('coin',@w);
SET @wnewvalue = CONCAT('(SELECT sum_coin FROM wview da WHERE wview1.fk_countrycode = da.country AND wview1.fk_categoryid = da.categoryid AND wview1.history_year = da.grab_year AND wview1.history_month = da.grab_month AND da.topx=',@w,' )');
SET @wfieldb = CONCAT('amount',@w);
SET @wnewvalueb = CONCAT('(SELECT sum_amount FROM wview da WHERE wview1.fk_countrycode = da.country AND wview1.fk_categoryid = da.categoryid AND wview1.history_year = da.grab_year AND wview1.history_month = da.grab_month AND da.topx=',@w,' )'); SET @wpre = CONCAT('UPDATE ',' wview1 ',' SET ',@wfield,'=',@wnewvalue,',',@wfieldb,'=',@wnewvalueb);
PREPARE stmt1 FROM @wpre ;
EXECUTE stmt1 ;
DROP PREPARE stmt1; SET @wmonth=@wmonth+1;
END WHILE ;
SET @wyear=@wyear+1;
END WHILE ;
SET @wyear = (SELECT MIN(grab_year) FROM grab_sales_rank_month);
SET @w=@w+10;
END WHILE ;
END/w/
DELIMITER ;
CALL insert_update_sales_rank_toparow_month;
CREATE INDEX w1 ON grab_sales_rank_month (country);
CREATE INDEX w11 ON grab_sales_rank_month (categoryid);
CREATE INDEX w12 ON grab_sales_rank_month (grab_year);
CREATE INDEX w13 ON grab_sales_rank_month (topx);
USING BTREE --->BETTER--->USING HASH
w-BIG TABLE-view+where-small table的更多相关文章
- 创建一个Table View
在本课程中,您将创建应用程序FoodTracker的主屏幕.您将创建第二个,表视图为主场景,列出了用户的菜谱.你会设计定制表格单元格显示每一个菜谱,它是这样的: 学习目标 在课程结束时,你将能够: 创 ...
- Table View Programming Guide for iOS---(六)---A Closer Look at Table View Cells
A Closer Look at Table View Cells A table view uses cell objects to draw its visible rows and then c ...
- Table View Programming Guide for iOS---(五)---Creating and Configuring a Table View
Creating and Configuring a Table View Your app must present a table view to users before it can mana ...
- How To Make A Swipeable Table View Cell With Actions – Without Going Nuts With Scroll Views
How To Make A Swipeable Table View Cell With Actions – Without Going Nuts With Scroll Views Ellen S ...
- 制作一个可以滑动操作的 Table View Cell
本文转载至 https://github.com/nixzhu/dev-blog Apple 通过 iOS 7 的邮件(Mail)应用介绍了一种新的用户界面方案——向左滑动以显示一个有着多个操作的菜单 ...
- 优化Table View
优化Table View Table view需要有很好的滚动性能,不然用户会在滚动过程中发现动画的瑕疵. 为了保证table view平滑滚动,确保你采取了以下的措施: 正确使用`reuseIden ...
- Creating a Table View Programmatically
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/TableView_iPhone/Cre ...
- sql: table,view,function, procedure created MS_Description in sql server
--添加描述 geovindu --https://msdn.microsoft.com/en-us/library/ms180047.aspx --https://msdn.microsoft.co ...
- iOS 利用长按手势移动 Table View Cells
本文译自:Cookbook: Moving Table View Cells with a Long Press Gesture 目录: 你需要什么? 如何做? 如何将其利用至UICollection ...
- iOS学习之Table View的简单使用
Table View简单描述: 在iPhone和其他iOS的很多程序中都会看到Table View的出现,除了一般的表格资料展示之外,设置的属性资料往往也用到Table View,Table View ...
随机推荐
- h5 canvas 画图
h5 canvas 画图 <!DOCTYPE html> <html lang="en"> <head> <meta charset=&q ...
- SOAPFaultException
javax.xml.ws.soap.SOAPFaultException: String index out of range: -6 at org.apache.cxf.jaxws.JaxWsCli ...
- Gym 100463A Crossings 逆序对
Crossings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100463 Description ...
- c++ queue 顺序队列的实现
#include<iostream> #include<cstdlib> #include<cstdio> using namespace std; const i ...
- 文件上传漏洞演示脚本之js验证
文件上传漏洞演示脚本之js验证 0 0 716 关于文件上传漏洞,想必玩web安全的同学们都有接触,之前本站也发布过一篇文章介绍文件上传漏洞的各种绕过方法,但是只是有文档却没有演示代码 ...
- div垂直居中 css div盒子上下垂直居中
div垂直居中 css div盒子上下垂直居中,让DIV盒子在任何浏览器中任何分辨率的显示屏浏览器中处于水平居中和上下垂直居中. div垂直居中常用于单个盒子,如一个页面里只有一个登录布局,使用div ...
- LightOJ1068 Investigation(数位DP)
这题要求区间有多少个模K且各位数之和模K都等于0的数字. 注意到[1,231]这些数最大的各位数之和不会超过90左右,而如果K大于90那么模K的结果肯定不是0,因此K大于90就没有解. 考虑到数据规模 ...
- Grunt配置文件编写技巧及示范
受益于grunt这么久,继续分享关于grunt的一些技巧.grunt确实是前端项目中不可或缺的提升效率的工具.第一次接触grunt是在去年7月份,开始有接触LESS.Coffee Script的等需要 ...
- AndroidのUI体验之ImmersiveMode沉浸模式
4.4带来了新的api——ImmersiveMode,可以使用户进入沉浸模式,享受更好的用户体验. 打开沉浸模式: /** * Detects and toggles immersive mode ( ...
- cocos2d ARCH_OPTIMAL_PARTICLE_SYSTEM这个未定义的问题
在新版本的cocos2d中ARCH_OPTIMAL_PARTICLE_SYSTEM已经被移除由 CCParticleSystemQuad取代 CCParticleSystem *test = [ARC ...