在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/ 數(shù)據(jù)庫問答
維他命 回答

刪除前是否要先查詢一次,這個個人覺得應視業(yè)務而定。正常情況是沒有這個必要,刪除通常按主鍵刪除,性能不是問題,但如果刪除的數(shù)據(jù)部分字段有緩存的話,應該先查一下,主要是為了方便清理緩存。舉個栗子:假如要刪除一個用戶,用戶的手機號存在于緩存中(比如已注冊手機號集合),此時直接刪除數(shù)據(jù)的話,緩存里的手機號就不會被移除,導致后來的人再也不能用這個手機號注冊,所以應先查詢,再刪除,查詢只是為了處理附加業(yè)務。

我只是從業(yè)務角度來講的,與性能無關(guān)。

傲寒 回答

自問自答,已經(jīng)解決了,是發(fā)送的包過大。具體來說是julia發(fā)送[34,0xa,0xb]會把第一個字節(jié)解釋為0x34而不是30+4導致包過長。

情皺 回答

sql1的 LIMIT 是全表掃描
sql2似乎是把結(jié)果存到緩存里, 再掃描.

我遇到過limit大表慢的情況, 但不用分組, 開始用的id查, 后來改游標了.

局外人 回答

看你的句子并不是想改字段名啊,而是改username的大小吧!如果是的話那么使用modify具體:alter table users modify username varchar(50) not null default '' comment '用戶名';

一般來說我設(shè)計數(shù)據(jù)庫基本not null的字段都有個默認值的,在庫設(shè)計上我基本不設(shè)計null值字段。

荒城 回答

mongodb服務器還需要在啟動時加一個auth參數(shù),文檔中這樣寫

Run the database (mongod process) with the --auth option to enable security. You must either have added a user to the admin db before starting the server with --auth, or add the first user from the localhost interface.

我也覺得這個設(shè)計很奇怪,為啥不直接缺省帶上呢。

疚幼 回答

《Redis實戰(zhàn)》第一章就簡單介紹你這樣的場景
redis處理高并發(fā)讀寫問題,既然是讀寫,那么讀和寫肯定使用redis去處理。

檸檬藍 回答

MyISAM這個引擎是專門為大量讀的場景而做的優(yōu)化, 很少寫,甚至沒有寫最好了。如用做CMS存儲引擎。

嚴格來說MyISAM引擎也并不是沒有事務管理。只是他的事務管理僅限于單表行記錄。

如果需要事物管理,用于類似比如交易場景,用這個引擎的話,就必須手工處理事物相關(guān)的操作,比如完整性一致性。

在這個場景下用InnoDB是更好的選擇。

硬扛 回答

強烈推薦時間戳,因為時間戳是數(shù)字類型的存儲本身會比字符串就快,而且數(shù)字的比對也比字符串容易
你可以用strtotime將字符串時間類型轉(zhuǎn)成時間戳 然后比較他們的大小
如果當前時間小于開始時間或者當前時間大于結(jié)束時間,那么優(yōu)惠券不可用
如果當前時間在開始時間和結(jié)束時間之間,就是可用

蔚藍色 回答

innodb帶主鍵表本身就是一個聚簇索引,所有數(shù)據(jù)保存在葉子節(jié)點中,但并不是說表本身就放在內(nèi)存中,mysql的內(nèi)存只緩存用到的部分數(shù)據(jù)

淚染裳 回答

在WiredTiger引擎中,每個索引對應磁盤上一個獨立的文件。刪除大量數(shù)據(jù)后,這個文件中對應的索引也被刪除了。但是空間是不會釋放的,只會盡可能重用。因為想釋放這些空間,就必須把空閑空間集中到文件尾,然后截斷。沒有哪個數(shù)據(jù)庫會主動做這個事情,既低效又沒多大意義。
如果實在想做,了解一下compact命令,既慢還阻塞。強烈不建議。

吃藕丑 回答

不需要寫,這是sequelize自帶的,這樣做是為了以便于你查詢的時候可以把關(guān)聯(lián)的內(nèi)容順帶查出來.

//查詢用戶記錄時候通過uid順便把用戶信息通過YepUserRef帶出來.
//sequelize通過你建立的連接調(diào)用get方法查出關(guān)聯(lián)信息

db.YepUserRecordRef.belongsTo(db.YepUserRef, {foreignKey: "yuid"});

YepUserRecordRef.findAll({
        where: {
            yuid: yuid
        },
        include: [YepUserRef]
    }).then(function (result) {
        callback(result)
    }).catch(function (err) {
        callback(err)
    });

以上都是我自己的理解,如有錯誤請指正.看見樓主再用sequelize,當初也用他寫過一些項目,如果有疑問可以隨時問我!(手動滑稽);
分享一下我當初學比較好的文檔 https://itbilu.com/nodejs/npm...

夢一場 回答

一般地,mongodb會自動插入一個唯一的_id字段作為pk

如果真的要自增,可以參考 https://docs.mongodb.com/v3.0...

簡單來講,就是:

  1. 建立一個自增計數(shù)器
  2. 創(chuàng)建一個函數(shù),使用findAndModify更新計數(shù)器(在update時用$inc進行自增)
  3. 插入記錄時,使用該函數(shù)獲得自增的ID

至于你說的定時任務,抱歉我沒看懂

不舍棄 回答

new formData可以傳入一個form標簽進去,form標簽內(nèi)所有的攜帶name屬性的表單元素會被認為是formItem

表單元素包含下列(可能還有其他的,但是不太常用了,2333):

  1. input
  2. textarea

如果你確定你數(shù)據(jù)的來源是一個div,那么很抱歉,直接new FormData是不能夠得到你想要的結(jié)果的
需要你自己在后邊進行append的操作:

formData.append('content', document.querySelector(".ql-editor").innerHTML)
寫榮 回答

select A.id,A.xmmc,count(distinct A1.id) cnt from A left join A1 on A.id<=A1.id and A.xmmc=A1.xmmc group by A.id
這種寫法執(zhí)行效率會更高,也容易理解內(nèi)在邏輯關(guān)系,同時當需要對次數(shù)進行分類整理時,case when寫起來也比較簡單。

舊時光 回答

可以根據(jù)以下兩個問答解決問題,結(jié)論是:key最好在數(shù)據(jù)變化時發(fā)生變化。key如果相同的話,列表不會全刷新。

Vue+Element-UI出現(xiàn)bug,刪除v-for列表中一項時數(shù)據(jù)對不上了

瞄小懶 回答

mybatis 的話這個可以實現(xiàn)的, 我之前是寫過一個類似的

表結(jié)構(gòu):

CREATE TABLE `admin_menu` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id',
  `name` varchar(64) NOT NULL COMMENT '菜單名',
  `parent_id` bigint(3) NOT NULL DEFAULT 0 COMMENT '父菜單的id, 如果是父菜單這個值為0',
  `url` varchar(500) NOT NULL DEFAULT '' COMMENT '菜單的鏈接',
  `icon` varchar(100) NOT NULL DEFAULT '' COMMENT '圖標',
  `menu_index` bigint(3) NOT NULL DEFAULT 0 COMMENT '展示的順序',
  `create_time` datetime NOT NULL COMMENT '創(chuàng)建時間',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新時間',
  PRIMARY KEY (`id`),
  KEY `uq_id` (`id`),
  KEY `uq_parent_id` (`parent_id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COMMENT='管理后臺的菜單';

其中parentId 跟你的typeParent類似, 記錄上一級的id


AdminMenu (Model):

public class AdminMenu implements Serializable {

    private static final long serialVersionUID = -6535315608269812875L;
    private int id;
    private String name;
    private int parentId;
    private String url;
    private String icon;
    private int menuIndex;
    private Date createTime;
    private Date updateTime;
    private List<AdminMenu> subMenus;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getParentId() {
        return parentId;
    }

    public void setParentId(int parentId) {
        this.parentId = parentId;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public int getMenuIndex() {
        return menuIndex;
    }

    public void setMenuIndex(int menuIndex) {
        this.menuIndex = menuIndex;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public List<AdminMenu> getSubMenus() {
        return subMenus;
    }

    public void setSubMenus(List<AdminMenu> subMenus) {
        this.subMenus = subMenus;
    }

    @Override
    public String toString() {
        return JsonUtil.toJson(this);
    }
}

Model的屬性跟表結(jié)構(gòu)一一對應, 最下面多了一個subMenu, 里面就是AdminMenu


下面是admin_menu.xml中的內(nèi)容

查詢SQL:

<select id="selectAllMenus" resultMap="adminMenuResult">
    SELECT
        id, name, parent_id, url, icon, menu_index, create_time, update_time
    FROM
      admin_menu
    WHERE parent_id=0
    ORDER BY menu_index
</select>

這里返回的就是adminMenuResult結(jié)果集:

<resultMap id="adminMenuResult" type="biz.menzil.admin.core.model.AdminMenu">
    <id column="id" property="id"/>
    <result column="name" property="name"/>
    <result column="parent_id" property="parentId"/>
    <result column="url" property="url"/>
    <result column="icon" property="icon"/>
    <result column="menu_index" property="menuIndex"/>
    <result column="create_time" property="createTime"/>
    <result column="update_time" property="updateTime"/>
    <association property="subMenus" column="id" select="selectSubMenus"/>
</resultMap>

其中這一行是最重要的

 <association property="subMenus" column="id" select="selectSubMenus"/>

這里用selectSubMenus來進行了另一個查詢, 查詢的參數(shù)為id, 把查詢出來的結(jié)果放在Model中的subMenus屬性中.

selectSubMenus查詢SQL:

<select id="selectSubMenus" parameterType="long" resultMap="adminSubMenuResult">
    select
      id, name, parent_id, url, icon, menu_index, create_time, update_time
    from admin_menu
    where parent_id = #{id}
    order by menu_index
</select>

這里就是用第一層的id來查詢有沒有子菜單. 這里的#{id}就是上面那個結(jié)果集的column參數(shù).
因為我只有兩層菜單, 所以這里用了一個新的結(jié)果集,跟上面的區(qū)別就是沒有subMenus字段.

adminSubMenuResult:

<resultMap id="adminSubMenuResult" type="biz.menzil.admin.core.model.AdminMenu">
    <id column="id" property="id"/>
    <result column="name" property="name"/>
    <result column="parent_id" property="parentId"/>
    <result column="url" property="url"/>
    <result column="icon" property="icon"/>
    <result column="menu_index" property="menuIndex"/>
    <result column="create_time" property="createTime"/>
    <result column="update_time" property="updateTime"/>
</resultMap>

如果你有三,四級的話你可以一個結(jié)果集. (第一層查詢的時候用id去查詢第二層, 第二層查詢的時候用第二層的id去查詢第三層...)


下面我貼一下整個的admin_menu.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="biz.menzil.admin.core.dao.AdminMenuDao">

    <resultMap id="adminMenuResult" type="biz.menzil.admin.core.model.AdminMenu">
        <id column="id" property="id"/>
        <result column="name" property="name"/>
        <result column="parent_id" property="parentId"/>
        <result column="url" property="url"/>
        <result column="icon" property="icon"/>
        <result column="menu_index" property="menuIndex"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
        <association property="subMenus" column="id" select="selectSubMenus"/>
    </resultMap>

    <resultMap id="adminSubMenuResult" type="biz.menzil.admin.core.model.AdminMenu">
        <id column="id" property="id"/>
        <result column="name" property="name"/>
        <result column="parent_id" property="parentId"/>
        <result column="url" property="url"/>
        <result column="icon" property="icon"/>
        <result column="menu_index" property="menuIndex"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <insert id="insertAdminMenu">
        INSERT INTO admin_menu(name, parent_id, url, icon, menu_index, create_time)
        VALUES (
        #{menu.name},
        #{menu.parentId},
        #{menu.url},
        #{menu.icon},
        #{menu.menuIndex},
        NOW()
        )
    </insert>

    <select id="selectById" resultMap="adminMenuResult">
        SELECT
            id, name, parent_id, url, icon, menu_index, create_time, update_time
        FROM
          admin_menu
        WHERE id = #{id}
    </select>

    <select id="selectAllMenus" resultMap="adminMenuResult">
        SELECT
            id, name, parent_id, url, icon, menu_index, create_time, update_time
        FROM
          admin_menu
        WHERE parent_id=0
        ORDER BY menu_index
    </select>

    <select id="selectSubMenus" parameterType="long" resultMap="adminSubMenuResult">
        select
          id, name, parent_id, url, icon, menu_index, create_time, update_time
        from admin_menu
        where parent_id = #{id}
        order by menu_index
    </select>

    <delete id="deleteAdminMenu">
        DELETE FROM
        admin_menu
        WHERE id=#{id}
    </delete>

    <update id="updateAdminMenu" >
        UPDATE admin_menu
        <set>
            <if test="menu.name != null and menu.name != ''">
                name=#{menu.name},
            </if>
            <if test="menu.parentId >= 0">
                parent_id=#{menu.parentId},
            </if>
            <if test="menu.url != null and menu.url != ''">
                url=#{menu.url},
            </if>
            <if test="menu.icon != null and menu.icon != ''">
                icon=#{menu.icon},
            </if>
            <if test="menu.menuIndex > 0">
                menu_index=#{menu.menuIndex},
            </if>
        </set>
        WHERE id=#{menu.id}
    </update>

</mapper>
掛念你 回答

@media媒體查詢,F(xiàn)ilter在css3中是一種特效,position元素定位,后邊同上

墨染殤 回答

你說的思路比較亂,先聚焦一下問題:

如果是持續(xù)的寫入壓力大,且超過單臺服務器磁盤IO寫入能力,最簡單的辦法就是mysql分為多個數(shù)據(jù)庫,保證數(shù)據(jù)能分布不同的磁盤設(shè)備上,以提升寫入的能力。

如果只是高峰期的寫入壓力大,可以考慮讀寫主要靠緩存的方案,后臺同步到數(shù)據(jù)庫,但這樣對緩存的可用性、數(shù)據(jù)預熱方面的要求較高。

java方面的優(yōu)化,主要是提高接入能力,和后端數(shù)據(jù)庫是否能支持大數(shù)據(jù)寫入沒關(guān)系。

呆萌傻 回答

原作者來答:
optimization.splitChunks.cacheGroups.common 配置項中,是 minSize 設(shè)置為 1。沒有minChunks屬性。

歡迎來原博客提問(回答會詳細點),原博客教程更新更快。

原文地址
更多教程地址