`
丁林.tb
  • 浏览: 790594 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

关于session variables 和 global variables

阅读更多

背景

    有同学问到这样一个问题:原来的binlog格式是statement,为什么执行了 set global binlog_format='row' set binlog_format='row',在binlog里面还是会看到有生成statement格式的事件?

 

变量分类

很多文章都说到MySQL的按照可见性范围分成两类 sessionglobal。实际上是三类 session_only, both, global_only.如下图见到的关系。

 

   

    session_only是仅线程级别意义的,比如 last_insert_id

    global_only 是仅全局级别有意义的,比如 sync_master_info

    both则是同时有全局和线程两个状态。这类变量需要特别注意它的规则:

    1) 每个新线程创建时从global获取值,设置为线程值

    2) 单独执行 set var_name=var_value时,只改变本线程的值,不改变global.value

       单独执行 set global var_name=var_value时,只改变全局的值,本线程的不改变

 

    前面说到的问题中,binlog_format就是这种both类的变量。因此即使两个命令都执行了,但是对于那些执行命令之前已经存在的长连接线程的本地值,仍然是statement,因此仍会生成statement格式的binlog 事件。

 

区分变量类型

既然有三种类型,那么如何区分呢。

在现在的MySQL各个版本中, show variables 是等效与 show session variables. 如果要看global类的,需要特别指明 show global variables. 但是这里容易造成一个误解。

需要明确的是, show global variables 是包含上图蓝色和绿色部分,show session variables 是包含全部!

这个效果是因为在执行show variables的时候,作了这么一个判断

// don't show session-only variables in SHOW GLOBAL VARIABLES”(来源于代码注释),但是对于show session variables这个命令,则无限制,因此显示所有的变量。不太合理 :(

 

因此如果要归纳那些session_only的,可以将这两个命令的结果作个diff。但要看global_only的就没有比较快捷的方法了。

   

  • 大小: 27.5 KB
0
0
分享到:
评论

相关推荐

    mysql中自增auto_increment功能的相关设置及问题

    涉及知识介绍: mysql服务器维护着2种mysql的系统参数(系统变量):全局变量(global variables)和会话变量(session variables)。它们的含义与区别如其各占的名称所示,session variables是在session级别的,对...

    标准pso代码-鲁.zip_On Strategy_algorithm,pso_cec2013_pso for decisio

    Large scale global optimization is an active research topic in the real-parameter optimization. Based on the analysis of the characteristics of large scale problems, a stochastic dynamic cooperative ...

    DMS_PSO.zip_On Strategy_algorithm_dms_dms-pso_dynamic pso

    Large scale global optimization is an active research topic in the real-parameter optimization. Based on the analysis of the characteristics of large scale problems, a stochastic dynamic cooperative ...

    PSO.zip_On Strategy_algorithm_article_cec2013_pso dynamic

    Large scale global optimization is an active research topic in the real-parameter optimization. Based on the analysis of the characteristics of large scale problems, a stochastic dynamic cooperative ...

    Libtasn1 库

    No global variables are used and multiple library handles and session handles may be used in parallel. It's portable. It should work on all Unix like operating systems, including Windows. The ...

    mysql 5.5 开启慢日志slow log的方法(log_slow_queries)

    set [session|global] long_query_time =0.2 # 设置时间.精确的毫秒 set global log_queries_not_using_indexes = on; # 设置无索引的查询 2.查看存放日志的形式 mysql> show variables like ‘log_output’; ...

    出现错误mysql Table ‘performance_schema…解决办法

    测试环境搭了一个mariadb 5.7,使用jdbc驱动 <groupId>mysql <artifactId>mysql-...Table 'performance_schema.session_variables' doesn't exist 问度娘无果,无奈升级MySQL驱动为5.1.36,解决。 据了解:

    tensorflow实现训练变量checkpoint的保存与读取

    saver = tf.train.Saver(tf.global_variables(),max_to_keep=1) #max_to_keep这个保证只保存最后一次training的训练数据 然后在训练的循环里面 checkpoint_path = os.path.join(Path, ‘model.ckpt’) saver.save...

    强化学习 —baseline项目之 TensorFlow的训练参数的存储和加载

    该项目中把tf的数据存储和读取抽取出两个函数,方便开发,思想和... variables = variables or tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES) ps = sess.run(variables) save_dict = {v.name: value for v, val

    tensorflow加载训练好的模型及参数(读取checkpoint)

    checkpoint 保存路径 model_path下存有包含多个迭代次数的...sess.run(tf.global_variables_initializer()) checkpoint_file=tf.train.latest_checkpoint(model_path) saver = tf.train.import_meta_graph({}.meta.for

    tensorflow 获取所有variable或tensor的name示例

    for variable_name in tf.global_variables(): print(variable_name) 获取所有tensor(每个op的输出张量)的name: for tensor_name in tf.contrib.graph_editor.get_tensors(tf.get_default_graph()): print...

    tensorflow 加载部分变量的实例讲解

    tensorflow模型保存为saver = tf.train.Saver()函数,saver.save()保存模型,代码如下: import tensorflow as tf v1= tf.Variable(tf.random_normal([784, 200], ... init_op = tf.global_variables_initializer()

    MNIST_data

    init = tf.global_variables_initializer() sess = tf.Session() sess.run(init) for i in range(1000): batch_xs, batch_ys = mnist.train.next_batch(100) sess.run(train_step, feed_dict={x: batch_xs, y_: ...

    [精典材料]Patran的PCL用户手册.doc

    To get all the nodes and their global coordinates 145 To get the topology of every element 146 To get the shape of every element 147 To get all the element connectivity for all elements 148 To get the...

    TensorFlow梯度求解tf.gradients实例

    我就废话不多说了,直接上代码吧! import tensorflow as tf w1 = tf.Variable([[1,2... tf.global_variables_initializer().run() print sess.run(res) print sess.run(grads) 输出结果为: [[4]] [array([[2, 1

    TensorFlow实现模型断点训练,checkpoint模型载入方式

    深度学习中,模型训练一般都需要很长的时间,由于很多原因,导致模型中断训练,下面介绍继续断点训练的方法。 方法一:载入模型时,不必指定迭代次数,... sess.run(tf.global_variables_initializer()) ckpt = tf.tr

    python学习教程:tensorflow实现训练变量checkpoint的保存与读取

    saver = tf.train.Saver(tf.global_variables(),max_to_keep=1) #max_to_keep这个保证只保存最后一次training的训练数据 然后在训练的循环里面 checkpoint_path = os.path.join(Path, ‘model.c

    解决TensorFlow程序无限制占用GPU的方法

    今天遇到一个奇怪的现象,使用tensorflow-gpu的时候,出现内存超额~~如果我训练什么大型数据也...init_op = tf.global_variables_initializer() with tf.Session() as sess: sess.run(init_op) print(sess.run(y)) 出

    tensorflow1.0 api

    a = tf.constant(36, name) b = tf.constant(10, name) c = tf.multiply(a,b) with tf.Session() as ... tf.global_variables_initializer() #初始化Tensorflow变量 with tf.Session() as session:#创建Session

    php.ini-development

    session.hash_bits_per_character ; Default Value: 4 ; Development Value: 5 ; Production Value: 5 ; short_open_tag ; Default Value: On ; Development Value: Off ; Production Value: Off ; track_errors ...

Global site tag (gtag.js) - Google Analytics