MySQL内核技术之"查询流程"

本节讨论MySQL是如何进行数据查询和读取的。首先看一下调用过程:

JOIN::exec()-->
do_select()-->
sub_select()-->
read_record()实际上是join_read_next()或join_read_first()-->
ha_index_next-->
index_next()实际上是ha_innobase::index_next()-->
general_fetch()-->
row_search_mvcc()

ha_innobase是从handler派生出来的,用来做实际查询的。里面的重要结构有:

/** Save CPU time with prebuilt/cached data structures */
row_prebuilt_t*        m_prebuilt;

/** Thread handle of the user currently using the handler;
this is set in external_lock function */
THD*            m_user_thd;

这里面最重要的是m_prebuilt结构,其中比较重要的几项:

btr_pcur_t*    pcur;        /*!< persistent cursor used in selects
                and updates */
innodb_session_t*
        session;    /*!< InnoDB session handler. */
/** The MySQL table object */
TABLE*        m_mysql_table;

/** The MySQL handler object. */
ha_innobase*    m_mysql_handler;

handler是由table调用的,常用的方式是table->file->**,这里的file实际上就是handler。而table在optimizer中被赋值的: TABLE_LIST *tl= select_lex->leaf_tables;,因为用了select_lex,就表明一个THD所有的操作都是共享table的。

m_prebuilt->pcur->btr_cur.page_cur.offsets

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值