Oracle、MySQL、PostgreSQL等数据库比较系列(十四): drop table being selected

对于一个连续7*24小时的业务,如果session 1正在select查询一张大表,而另一个session尝试drop 相同的表,会发生什么?对于最流行的MVCC数据库oracle,mysql,postgreql需要对比,因为drop不只是字典表更新标记,还需要回收物理空间。在这几个数据库中的表现一样吗?Oceanbase和goldenDB及GreatDB的表现.

PostgreSQL/openGauss explain解析(二): indexonlyscan cost

PostgreSQL系(openGASUSS)数据库中的所有索引都是二级索引, 数据表段( heap)和索引段(index)分别存储,通常对于多列表的SQL只返回或where中仅少量的列时,希望可以只从索引中检索,而不用再从索引回表返回数据(本篇不考虑可见性)提高查询效率,像在oracle中有index full scan和index fast full scan的执行计划,在Postgresql中也支持Btree index的indexonlyscan, MySQL中同样支持,但发现PostGreSQL默认配置的SQL优化器通常判断索引的cost大于表扫描,导致仅查询索引列也未使用索引

“alter table ” modify column in Oracle、MySQL、PostGreSQL(数据库比较系列十三)

‘alter table’ DDL操作后期运维时比较常规的操作,但在oracle,MySQL,PostGreSQL中行为并不相同,Oracle还是三者中代价最低的,但是在Oracle DBA转向其它数据库运维时,以O的经验维护像MySQL、PostGreSQL时修改列的小动作可能会出现故障,比如空间耗尽、持续时间长、锁、执行计划变等现象。这篇分别测试一下三个数据库在ALTER TABLE modify column上的影响。

multi-version read consistency in Oracle、MySQL、PostGreSQL(数据库比较系列十二)

ANSI/ISO SQL 标准定义了4 种事务隔离级别,对于相同的事务,采用不同的隔离级别分别有不同的结果。这些隔离级别是根据3 个“现象”定义的,在Oracle 中READ COMMITTED 则有得到读一致查询所需的所有属性,在其他数据库中的读READ COMMITTED 可能会有不同的答案, 最近有个客户在测试migrate oracle to postgreSQL测试发现一个批处理的结果并非一致,

VIEW dependencies in Oracle、MySQL、PostGreSQL(数据库比较系列十一)

在有些程序员开发习惯中,喜欢为了应用代码的简洁或复用,而在数据库创建一个复杂关连查询的VIEW,甚至是VIEW套VIEW嵌套使用, 这里就有个问题如果上线后如发现依赖的表字段类型或长度不足时,修复一个view依赖的table列时发现在oracle、mysql、postgresql(本篇等同pg)中有不同的表现, 尤其是使用postgresql的用户需要格外注意, 因为pg 不允许直接修改

列顺序占用存储大小的影响 in Oracle、MySQL、PostGreSQL(数据库比较系列十)

在创建表时,如果相同的列类型,不同表列的顺序是否会影响数据库占用空间大小?使用oracle、mysql或postgresql是不是相同的表现呢? 不是的Postgresql近期发现空间使用会因为columns的顺序而占用不同的大小,当然也和实际的数据有关,简单的测试。

How to get error message from error code on Oracle , MySQL, PostgreSQL(数据库比较系列九)

数据库运行过程中在错误日志或SQL运行时报错难以避免,oracle预制了好多错误代码,也有不确定性的会在ora-600 700 7445中, 所以Oracle DBA通常是先看ORA-xxxxx编号的错误,确认是否与数据库层相关,oracle database提供了一个命令行工具oerr工具查看错误代码的message和一些很友善action简单的处理建议。 好奇其它两个主流开源数据库有没有相同的工具?这里简单的记录

How to Change in SQL Prompt format in Oracle , MySQL, PostgreSQL(数据库比较系列七)

像UNIX的PS1环境变量可以改变shell操作提示符, 在日常工作环境中可以提升一些效率可以防止一些误操作, 很多年前在看tom关于在练习oracle操作前的一些环境配置像login.sql, 还可以显示当前的用户或数据库名很是欣喜, 下面记录Oracle , MySQL, PostgreSQL三个主流数据库改变命令行提示符的方法。

Differences between MySQL AUTO_INCREMENT 5.7 VS 8.0

AUTO_INCREMENT机制用于 InnoDB表, AUTO_INCREMENT必须将列定义为某个索引的第一列或唯一列,可以对表执行等效的索引 SELECT MAX(ai_col) 查找以获得最大列值。上AUTO_INCREMENT列h索引没有要求必须是是 PRIMARY KEY 或 UNIQUE,但为了避免 列中的重复值,建议使用这些索引类型。在一些情况下MySQL5.7中会产生重复值duplicate-key error, 8.0有所改变。

How to find full table scan SQL in Oracle,MySQL,Postgresql ?(数据库比较系列五)

Queries that do “full table scan” are the ones that don’t use indexes. However, it is more suitable to use a full table scan for small tables, and it will not cause performance problems. Or when the data on the large table is seriously skewed and a large proportion of data records need to be returned, a full table scan will also be better than an index scan.

How to config Keepalived VIP Auto Failover for MySQL?

MySQL master slave replication doesn’t provide any solution in case of master failure, in that scenarios we have to manually do the configuration changes to make the next available server as master. Use keepalived to configure VIP, the application uses VIP to connect to the database, when the node is unavailable, the VIP automatically switches to other nodes.

How to start MySQL slave/replica skip missing binlogs?

Got fatal error 1236 from master when reading data from binary log: ‘Could not find first log file name in binary log index file’

Sometimes our MySQL master-slave environment has not been used for a long time,slave server is stopped for some reason for a few hours/days, and the master binlog has been automatically deleted. when you resume replication on the slave it fails with above error, and I don’t care about the loss of transactions between them in my test DB. Of course, the production environment may need to rebuild the slave database.