SQL

数据库无服务器架构

问题 长链接 通过连接池和数据库保持长链接 Amazon Aurora Serverless is an on-demand, auto-scaling configuration for Amazon Aurora (MySQL-compatible and PostgreSQL-compatible editions), where the database will automatically start up, shut down, and scale capacity up or down based on your application’s needs. It enables you to run your database in the cloud without managing any database instances. It’s a simple, cost-effective option for infrequent, intermittent, or unpredictable workloads.

Mysql High Performance

InnoDB MySQL 5.1 shipping the older version of InnoDB, If you’re using MySQL 5.1, please ensure that you’re using the InnoDB plugin. It’s much better than the older version of InnoDB. It now scales well to 24 CPU cores, and arguably up to 32 or even more cores depending on the scenario

Having Multiple Tables in FROM and Using JOIN

INNER JOIN = JOIN INNER JOIN is the default if you don’t specify the type when you use the word JOIN INNER JOIN is ANSI syntax that you should use. Why Use the New Syntax for SQL Joins? Join conditions are separate from filtering conditions Easier to join multiple tables

Mysql Relocate the Data Directory

cp data file cp /var/lib/mysql /data -Rf chown -R mysql:mysql /data/mysql AppArmor /etc/apparmor.d/local/usr.sbin.mysqld /data/mysql r, /data/mysql/** rwk, sudo systemctl reload apparmor sudo as myql sudo -s -u mysql mysql 时间类型支持微秒 MySQL permits fractional seconds for TIME, DATETIME, and TIMESTAMP values, with up to microseconds (6 digits) Mysql DATETIME(6) DATETIME[(fsp)] The fsp value, if given, must be in the range 0 to 6. A value of 0 signifies that there is no fractional part.

Postgres Notes

postgres in docker https://github.com/wubigo/docker-compose/blob/main/docker-compose-psql.yml 启用pg_stat_statements docker volume inspect root_postgresql_data |grep "Mountpoint" echo "shared_preload_libraries = 'pg_stat_statements'" > /var/lib/docker/volumes/root_postgresql_data/_data/pgdata/postgresql.conf INSTALL sudo apt-get install -y postgresql-client psql --version TEST psql -h cmp.clv6a9yh.ap-northeast-1.rds.amazonaws.com -U postgres postgres=> \list List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+-------------+-------------+----------------------- postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | rdsadmin | rdsadmin | UTF8 | en_US.UTF-8 | en_US.

install Mysql 5 on Ubuntu20

select myql 5.7 wget wget https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb dpkg -i mysql-apt-config_0.8.12-1_all.deb turns off the GPG check sources.list.d/mysql.list deb [trusted=yes] http://repo.mysql.com/apt/ubuntu/ bionic mysql-5.7 install mysql and create admin user sudo apt update apt-cache policy mysql-server | grep 5.7 sudo apt install mysql-client=5.7.37-1ubuntu18.04 mysql-community-server=5.7.37-1ubuntu18.04 mysql -u root -p GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' IDENTIFIED BY 'pass' WITH GRANT OPTION