DB中BLOB 二进制字段,大多数存放的是照片。可以将其放到共享存储里。进行优化。
那么DB里的text 字段,应该如何优化?
案例如下
MariaDB [lvanclub_live]> show create table lvan_apks;
+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| lvan_apks | CREATE TABLE `lvan_apks` (
`apk_id` bigint(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '软件包 ID',
`app_id` int(11) NOT NULL COMMENT '应用 ID',
`cp_id` int(11) NOT NULL COMMENT '游戏开发商 ID',
`name` varchar(100) NOT NULL COMMENT '游戏名称',
`icon` varchar(255) NOT NULL COMMENT '游戏图标',
`summary` varchar(255) NOT NULL COMMENT '软件简短介绍',
`description` text NOT NULL COMMENT '软件详细介绍',
`point` int(11) DEFAULT NULL COMMENT '积分',
`apk_size` int(11) NOT NULL COMMENT '软件包大小',
`apk_md5` varchar(50) NOT NULL COMMENT '软件包 md5 校验值',
`apk_package` varchar(100) NOT NULL COMMENT '软件包名,大小写敏感',
`apk_url` varchar(250) NOT NULL COMMENT 'APK 包下载地址',
`version_name` varchar(20) NOT NULL COMMENT '软件版本名称',
`version_code` int(11) NOT NULL COMMENT '软件内部版本号',
`min_os_version` int(11) DEFAULT NULL COMMENT '软件所需最低系统版本',
`screenshots` text NOT NULL COMMENT '截图, 一行一个, 不同尺寸截图之间用 | 分割',
`permissions` text COMMENT '软件需要的权限,一行一个',
`features` text COMMENT '软件需要的功能,一行一个',
`keywords` varchar(255) DEFAULT NULL COMMENT '软件关键词',
`network_provider` tinyint(4) NOT NULL COMMENT '网络运营商 (0:全网, 1:移动, 2:联通, 3:电信)',
`apk_type` tinyint(4) NOT NULL COMMENT '软件类型(0:单机, 1:网游, 2:应用)',
`pay_type` tinyint(4) NOT NULL COMMENT '资费类型(0:免费, 1:收费)',
`download_num` int(11) DEFAULT '0' COMMENT '软件下载量',
`download_num_weight` int(11) DEFAULT '0' COMMENT '软件下载量加权',
`score` float(3,1) DEFAULT '0.0' COMMENT '软件评分',
`score_weight` float(3,1) DEFAULT '0.0' COMMENT '软件评分加权',
`status` tinyint(3) NOT NULL COMMENT '软件状态 - 状态码:-1-应用下架( 商店内不可见);0-草稿(商店内不可见);5-应用上架;\r\n目前上线流程比较简单,因此暂时在后台界面中隐藏状态1, 2, 3, 4,1-待审核(商店内不可见);2-接入中(商店内不可见);3-接入完成,待测试(商店内不可见);4-测试完成,待上架(商店内不可见);',
`sort` smallint(6) NOT NULL DEFAULT '1000' COMMENT '排序字段,默认值1000,从小到大顺序排列',
`sort_top_game_new` smallint(6) DEFAULT '1000' COMMENT '排序字段(排行/新品),默认值1000,从小到大顺序排列',
`sort_top_game_online` smallint(6) DEFAULT '1000' COMMENT '排序字段(排行/网游),默认值1000,从小到大顺序排列',
`sort_top_game_singleplayer` smallint(6) DEFAULT '1000' COMMENT '排序字段(排行/单机),默认值1000,从小到大顺序排列',
`sort_top_game_hot` smallint(6) DEFAULT '1000' COMMENT '排序字段(排行/热门),默认值1000,从小到大顺序排列',
`publish_ts` int(11) DEFAULT NULL COMMENT 'APK 上架时间戳',
`update_ts` int(11) NOT NULL COMMENT '更新时间戳',
PRIMARY KEY (`apk_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1702 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT |
+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
MariaDB [lvanclub_live]> select * from lvan_apks limit 1;
+--------+--------+--------+--------------------------+--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------+----------+----------------------------------+--------------------+--------------------------------------------+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+---------------+------------------+----------+----------+--------------+---------------------+-------+--------------+--------+------+-------------------+----------------------+----------------------------+-------------------+------------+-----------+
| apk_id | app_id | cp_id | name | icon | summary | description | point | apk_size | apk_md5 | apk_package | apk_url | version_name | version_code | min_os_version | screenshots | permissions | features | keywords | network_provider | apk_type | pay_type | download_num | download_num_weight | score | score_weight | status | sort | sort_top_game_new | sort_top_game_online | sort_top_game_singleplayer | sort_top_game_hot | publish_ts | update_ts |
+--------+--------+--------+--------------------------+--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------+----------+----------------------------------+--------------------+--------------------------------------------+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+---------------+------------------+----------+----------+--------------+---------------------+-------+--------------+--------+------+-------------------+----------------------+----------------------------+-------------------+------------+-----------+
| 1 | 102041 | 101035 | 雷霆战机2(完美版) | 3/3/4/3345c96f38c55ca1deecacfb36a6c5c8.png | 经典雷电豪华升级版,好评如潮!舒适触屏体验,HD震撼画面!驾驶变形机器人,大战异型飞船!超级华丽BOSS战,火爆空战精彩纷呈! | 游戏特色:
1、画面:整体美观、细节华丽,BOSS威武霸气,爆炸场面震撼。
2、音效:背景音乐与游戏完美结合,音效精彩演绎更是极具临场感。
3、剧情:精美的CG让游戏带入感十足,剧情的发展跌宕起伏,引人入胜。
4、操作:游戏操作方便,难度控制很好,躲过***后成就感极强 | 1 | 9896829 | 366676c5b1bbe4c418f4bd1053bcc128 | a5game.leidian2_MM | 7/9/8/79876aa2d451940a6905aeb11c5fca13.apk | 1.01.00 | 10100 | 4 | d/5/d/d5d0aa01b07ae435969b19075a63c3b2.jpg|d/5/d/d5d0aa01b07ae435969b19075a63c3b2.jpg?imageView2/w/164/h/274
2/b/a/2ba9a00a13c1b29eb907d52b00f7ef63.jpg|2/b/a/2ba9a00a13c1b29eb907d52b00f7ef63.jpg?imageView2/w/164/h/274
3/f/4/3f485c8be792705f63accf805e0bd3b5.jpg|3/f/4/3f485c8be792705f63accf805e0bd3b5.jpg?imageView2/w/164/h/274
6/9/9/6997845643b74dea0b11525ed34db56d.jpg|6/9/9/6997845643b74dea0b11525ed34db56d.jpg?imageView2/w/164/h/274
| android.permission.MOUNT_UNMOUNT_FILESYSTEMS|android.permission.INTERNET|android.permission.ACCESS_NETWORK_STATE|android.permission.ACCESS_WIFI_STATE|android.permission.CHANGE_WIFI_STATE|android.permission.CHANGE_NETWORK_STATE|android.permission.WRITE_EXTERNAL_STORAGE|android.permission.SEND_SMS|android.permission.READ_PHONE_STATE|android.permission.READ_CONTACTS|android.permission.WRITE_APN_SETTINGS|android.permission.GET_ACCOUNTS|android.permission.VIBRATE | android.hardware.wifi|android.hardware.telephony|android.hardware.touchscreen | 飞机 射击 | 0 | 0 | 1 | 54 | 99 | 0.0 | 4.0 | 0 | 1000 | 1000 | 1000 | 1000 | 1000 | NULL | 0 |
+--------+--------+--------+--------------------------+--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------+----------+----------------------------------+--------------------+--------------------------------------------+--------------+--------------+----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------+---------------+------------------+----------+----------+--------------+---------------------+-------+--------------+--------+------+-------------------+----------------------+----------------------------+-------------------+------------+-----------+
1 row in set (0.00 sec)
本文出自 “晴空” 博客,谢绝转载!