DB

バイナリログ書き込み時の圧縮

DB

MySQL (8.0.26)https://gihyo.jp/dev/serial/01/mysql-road-construction-news/0165バイナリログトランザクション圧縮 MySQL 8.0.20 から、MySQL サーバーインスタンスでバイナリログトランザクション圧縮を有効にできます。 バイナリログのトランザクション…

インラインビューやサブクエリを含むSQLのヒント句指定方法

DB

MySQL (8.0.26) テーブル最小要素="グループ化されていないテーブル又はグループ化されている場合はグループ化後のビュー" -- 結合ヒントNO_BNLヒントで確認 グループ化されていないインラインビューの場合、本体側にインラインビュー内のテーブル名を問合せ…

サブクエリと結合ヒント句

DB

MySQL (8.0.26) https://qiita.com/hmatsu47/items/e473a3e566b910d61f5b -- 1. テストデータ作成 drop table tab1;create table tab1( col1 bigint ,col2 bigint ); drop table tab2;create table tab2( col1 bigint ,col2 bigint ); drop table tab3;creat…

サブクエリとアクセスヒント句

DB

MySQL (8.0.26)-- 1. テストデータ作成 drop table tab1;create table tab1( col1 bigint ,col2 bigint ); drop table tab2;create table tab2( col1 bigint ,col2 bigint ); drop table tab3;create table tab3( col1 bigint ,col2 bigint ); drop procedur…

サブクエリとleadingヒント句

DB

MySQL (8.0.26)-- 1. テストデータ作成 drop table tab1;create table tab1( col1 bigint ,col2 bigint ); drop table tab2;create table tab2( col1 bigint ,col2 bigint ); drop table tab3;create table tab3( col1 bigint ,col2 bigint ); drop procedur…

ビューとleadingヒント句

DB

MySQL (8.0.26) -- 1. テストデータ作成 drop table tab1;create table tab1( col1 bigint ,col2 bigint ); drop table tab2;create table tab2( col1 bigint ,col2 bigint ); drop table tab3;create table tab3( col1 bigint ,col2 bigint ); drop procedu…

インラインビューとleadingヒント句

DB

MySQL (8.0.26) -- 1. テストデータ作成 drop table tab1;create table tab1( col1 bigint ,col2 bigint ); drop table tab2;create table tab2( col1 bigint ,col2 bigint ); drop table tab3;create table tab3( col1 bigint ,col2 bigint ); drop procedu…

ビューとアクセスヒント句

DB

MySQL (8.0.26) drop table tab1;create table tab1( col1 bigint ,col2 bigint ); drop table tab2;create table tab2( col1 bigint ,col2 bigint ); drop table tab3;create table tab3( col1 bigint ,col2 bigint ); drop procedure proc1; delimiter //c…

ビューと結合ヒント句

DB

MySQL (8.0.26) https://qiita.com/hmatsu47/items/e473a3e566b910d61f5b drop table tab1;create table tab1( col1 bigint ,col2 bigint ); drop table tab2;create table tab2( col1 bigint ,col2 bigint ); drop table tab3;create table tab3( col1 bigi…

インラインビューとアクセスヒント句

DB

MySQL (8.0.26) -- 1. テストデータ作成 drop table tab1;create table tab1( col1 bigint ,col2 bigint ); drop table tab2;create table tab2( col1 bigint ,col2 bigint ); drop table tab3;create table tab3( col1 bigint ,col2 bigint ); drop procedu…

インラインビューと結合ヒント句

DB

MySQL (8.0.26) https://dev.mysql.com/doc/refman/8.0/ja/hash-joins.htmlhttps://qiita.com/hmatsu47/items/e473a3e566b910d61f5b -- 1. テストデータ作成 drop table tab1;create table tab1( col1 bigint ,col2 bigint ); drop table tab2;create table …

deleteとinsertの速度比較

DB

Oracleはinsertのほうが早いMySQL,PostgreSQL,SQL Serverはdeleteのほうが早い MySQL (8.0.26) -- 1. テストデータ作成 drop table tab1;create table tab1( col1 bigint ,col2 varchar(1000) ,col3 varchar(1000) ,col4 varchar(1000) ,col5 varchar(1000) …

HJでのインデックスフルスキャンとテーブルフルスキャンの比較

DB

MySQL (8.0.26) -- 1. テストデータ作成 drop table tab1;create table tab1( col1 bigint ,col2 varchar(1000)-- ,col3 varchar(1000)-- ,col4 varchar(1000)-- ,col5 varchar(1000)-- ,col6 varchar(1000)-- ,col7 varchar(1000)-- ,col8 varchar(1000)-- …

ヒント句の分割指定

DB

MySQL (8.0.26) drop table tab1;create table tab1( col1 bigint ,col2 bigint ); drop table tab2;create table tab2( col1 bigint ,col2 bigint ); drop procedure proc1; delimiter //create procedure proc1(in x int)begin declare i int; set i = 0; …

in句件数の実行計画への影響

DB

MySQL (8.0.26) drop table tab1;create table tab1( col1 bigint ,col2 bigint ); drop table tab2;create table tab2( col1 bigint ,col2 bigint ); drop procedure proc1; delimiter //create procedure proc1(in x int)begin declare i int; set i = 0; …

select句にSQLを書く場合とJOINする場合の比較

DB

MySQL (8.0.26) -- 1. テストデータ作成 drop table tab1;create table tab1( col1 bigint ,col2 bigint ); drop table tab2;create table tab2( col1 bigint ,col2 bigint ); drop procedure proc1; delimiter //create procedure proc1(in x int)begin dec…

ヒント句一覧

DB

MySQL (8.0.26) インデックスヒントhttps://dev.mysql.com/doc/refman/8.0/ja/index-hints.html USE INDEXIGNORE INDEXFORCE INDEX オプティマイザヒントhttps://dev.mysql.com/doc/refman/8.0/ja/optimizer-hints.html BKANO_BKABNLNO_BNLDERIVED_CONDITION…

アラートログ出力先変更

DB

MySQL (8.0.26) mkdir -p /home/mysql/{general,slowquery,binlog,error}chown -R mysql:mysql /home/mysql vim /etc/my.cnf:set paste # 一般クエリログ(General query log)general_log=1general_log_file="/home/mysql/general/general.log" # スローク…

DBファイル移動時のDMLへの影響

DB

MySQL (8.0.26)https://qiita.com/terra_yucco/items/6e4f02f8aaff25529dec -- 1. データファイル移動先の準備mkdir -p /home/mysql/tbs1chown -R mysql:mysql /home/mysql vim /etc/my.cnfinnodb_directories=/home/mysql systemctl restart mysqld select …

データベースファイル移動

DB

MySQL (8.0.26)https://ez-net.jp/article/4B/v4oWna5J/kpwT0SuSlcvA/https://qiita.com/ShuM/items/1a960b4ef53f8a08dd5ahttps://dev.mysql.com/doc/refman/8.0/ja/general-tablespaces.html#general-tablespaces-moving-non-partitioned-tables データディ…

全角スペースの影響

DB

MySQL (8.0.26)mysqlで確認 drop table tab1;create table tab1(col1 bigint);create unique index ind1 on tab1(col1); drop procedure proc1; delimiter //create procedure proc1(in x int)begin declare i bigint; set i = 0; start transaction; while …

非同期コミットパラメータ

DB

MySQL (8.0.26) show variables like 'innodb_flush_log_at%'; innodb_flush_log_at_trx_commit 0 ログは 1 秒に 1 回書き込まれ、ディスクにフラッシュされます1 (デフォルト) ログは、トランザクションのコミットごとにディスクに書き込まれ、フラッシュさ…

管理者用接続

DB

MySQL (8.0.26)https://gihyo.jp/dev/serial/01/mysql-road-construction-news/0164 -- 接続数上限パラメータshow variables like '%max_connection%'; max_connections 許可される最大のクライアントの同時接続数。デフォルト151mysqlx_max_connections X …

パラメータ渡し

DB

MySQL (8.0.26)https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q11176009486 drop table tab1;create table tab1(col1 int, col2 varchar(1));insert into tab1 values(1,'A');insert into tab1 values(2,'B');insert into tab1 values(3,'C');s…

動的SQLの実行計画確認

DB

MySQL (8.0.26) drop table tab1; create table tab1( col1 int primary key, col2 int, col3 int, col4 int) partition by range (col1) ( partition p1 values less than (0) , partition p2 values less than (maxvalue) ); set @sSQL := concat(" explai…

パーティションキー更新

DB

MySQL (8.0.26) drop table tab1; create table tab1( col1 int primary key, col2 int, col3 int, col4 int) partition by range (col1) ( partition p1 values less than (0) , partition p2 values less than (maxvalue) ); insert into tab1 values(-1,0…

ダンプのデータとシーケンスの一貫性

DB

MySQL (8.0.26) auto_incrementで採番した値をインサートしながらダンプ取得このダンプをインポートしてauto_incrementとテーブルデータの整合性を確認する drop table tab1;create table tab1(col1 int auto_increment primary key); drop procedure proc1;…

クラスタ+レプリケーション(レプリケーション先もクラスタ)

DB

MySQL (8.0.27)OS: CentOS7メモリ2G/ディスク60G https://blog.s-style.co.jp/2021/11/8297/https://dev.mysql.com/doc/mysql-shell/8.0/en/innodb-clusterset.htmlhttps://www.mysql.com/jp/why-mysql/presentations/mysql-innodb-clusterset-doc-jp/ ※Inno…

テーブルカラム確認コマンド

DB

MySQL (8.0.26) describe tab1;desc tab1; show full columns from tab1;show columns from tab1; Oracle (19c) describe tab1desc tab1 PostgreSQL (14)\d tab1 SQL Server (2019)https://ameblo.jp/m-o-q/entry-12689546440.html sp_help tab1

connect文

DB

MySQL (8.0.26) connect test\r test \r test mmm066\r test mmm050 Oracle (19c) connect test/test@pdb1conn test/test@pdb1 conn test/test@mmm065:1521/pdb1.example.com conn test/test@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=mmm065)(PORT=1521))…