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 ...
随机推荐
- 滚屏加载--jQuery+PHP实现浏览更多内容
滚屏加载技术,就是使用Javascript监视滚动条的位置,每次当滚动条到达浏览器窗口底部时,触发一个Ajax请求后台PHP程序,返回相应的数据,并将返回的数据追加到页面底部,从而实现了动态加载,其实 ...
- PHP 图片水印类
<?php /** * 加水印类,支持文字图片水印的透明度设置.水印图片背景透明. * $obj = new WaterMask($imgFileName); //实例化对象 * $obj-&g ...
- 【练习】ViewPager标签滑动
效果图: 布局: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:a ...
- CodeForces 404C Ivan and Powers of Two
Ivan and Powers of Two Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & % ...
- 线段树 Codeforces Round #197 (Div. 2) D. Xenia and Bit Operations
题目传送门 /* 线段树的单点更新:有一个交叉更新,若rank=1,or:rank=0,xor 详细解释:http://www.xuebuyuan.com/1154895.html */ #inclu ...
- Win7系统删除微软拼音
微软拼音会在使用Office时偷偷的安装,都找不到删除的地方.在网上找了很多方法都不灵光,最后用下面的方法成功删除. 在语言设置窗口里,重新添加一次这个输入法,确定保存,然后再删除,就行了. 这个 ...
- BZOJ3217 : ALOEXT
替罪羊树套Trie,Trie合并用线段树合并,注意常数优化. 顺便AC800题纪念~~~ #include<cstdio> #include<cmath> #include&l ...
- Distributed RPC —— 分布式RPC
This tutorial showed how to do basic stream processing on top of Storm. There's lots more things you ...
- Session赋值(备注)
Session赋值也是在后台赋,不是在前台赋 追问 不好意思 那还真能在AJAX中赋值 我已经解决了 加一个接口IRequiresSessionState 就OK 提问者评价 太感谢了,真心有用
- NOIP200107统计单词个数
NOIP200107统计单词个数 难度级别: A: 编程语言:不限:运行时间限制:1000ms: 运行空间限制:51200KB: 代码长度限制:2000000B 试题描述 给出一个长度不超过200的由 ...