`
stephen80
  • 浏览: 103996 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

mysql 自动启动,和 best practice

阅读更多
/etc/init.d/mysql restart

http://drupalsh.cn/Linux-apache-mysql-autostart

    * 确保/etc/rc.d/init.d/mysqld 存在,用service mysqld start能够正常启动
    * 运行命令:chkconfig --add mysqld
    * 运行命令: chkconfig --level 345 mysqld on
    * 重启即可

Myisam is preferred without transaction and little update(delete)
Big than 4G datafile can user Myisam merge table.

InnoDB with auto_increment primary key is preferred.
Few storage process
Guess: 20m records max per table , 500G data max per tablespace , 256 tables per database (may problem)
Use prepared statement and  batch
Optimize Your Queries For the Query Cache
// query cache does NOT work
$r = mysql_query("SELECT username FROM user WHERE signup_date >= CURDATE()");

// query cache works!
$today = date("Y-m-d");
$r = mysql_query("SELECT username FROM user WHERE signup_date >= '$today'");

EXPLAIN Your SELECT Queries
LIMIT 1 When Getting a Unique Row

Index and Use Same Column Types for Joins

Do Not ORDER BY RAND()

Avoid SELECT *
t is a good habit to always specify which columns you need when you are doing your SELECT's.

Use ENUM over VARCHAR

Use NOT NULL If You Can

Store IP Addresses as UNSIGNED INT (?)

Fixed-length (Static) Tables are Faster

Vertical Partitioning

Vertical Partitioning is the act of splitting your table structure in a vertical manner for optimization reasons.
Example 1: You might have a users table that contains home addresses, that do not get read often. You can choose to split your table and store the address info on a separate table. This way your main users table will shrink in size. As you know, smaller tables perform faster.
Example 2: You have a "last_login" field in your table. It updates every time a user logs in to the website. But every update on a table causes the query cache for that table to be flushed. You can put that field into another table to keep updates to your users table to a minimum.
But you also need to make sure you don't constantly need to join these 2 tables after the partitioning or you might actually suffer performance decline.

Split the Big DELETE or INSERT Queries

If you have some kind of maintenance script that needs to delete large numbers of rows, just use the LIMIT clause to do it in smaller batches to avoid this congestion.

Smaller Columns Are Faster
Use an Object Relational Mapper
f you do not need the time component, use DATE instead of DATETIME.

Consider horizontally spitting many-columned tables if they contain a lot of NULLs or rarely used columns.
Be an SQL programmer who thinks in sets, not procedural programming paradigms

InnoDB can't optimize SELECT COUNT(*) queries. Use counter tables! That's how to scale InnoDB.
Prefer MM with hive




refer :
http://blog.tuvinh.com/top-20-mysql-best-practices/
分享到:
评论

相关推荐

    MGR Best Practice - 娄帅 - 20210522.pdf

    MGR与传统的异步复制机制相比,最大的特点是采用了多数派节点接收事务消息的PAXOS算法,并且可以自动处理故障切换、集群成员变化和选主等问题。 在MGR的架构中,有四个关键组件:Capture、Applier、Recovery和...

    MYSQL数据库世界五百强应用一例.pdf

    MYSQL数据库架构设计要点总结 MYSQL数据库架构设计是数据库管理和维护的重要组成...读者可以通过本文对MYSQL数据库架构设计要点和思路的总结和分析,来更好地理解和掌握MYSQL数据库架构设计的要点和best practice。

    创建MySQL用户赋予某指定库表的权限[文].pdf

    MySQL 权限管理-best practice 是指 MySQL 权限管理的最佳实践。以下是 MySQL 权限管理-best practice: * 使用 GRANT 语句授予用户权限。 * 使用 REVOKE 语句撤销用户权限。 * 使用 SHOW GRANTS 语句显示用户权限...

    《PHP & MySQL: Novice to Ninja, 6th Edition》- 2017 英文原版

    on guide to learning all the tools, principles, and techniques needed to build a professional web application using PHP & MySQL. Comprehensively updated to cover PHP 7 and modern best practice,...

    Ecology9安装部署手册V8.0

    * Mysql 的安装和配置需要遵循相应的安全指南和best practice,以确保数据的安全和完整性。 2.4 达梦安装部署 * 达梦是一种流行的关系数据库管理系统,Ecology9 应用系统支持 达梦的安装和配置。 * 在安装 达梦...

    《PHP & MySQL: Novice to Ninja, 6th Edition》2017 英文原版 Kindle - mobi格式

    on guide to learning all the tools, principles, and techniques needed to build a professional web application using PHP & MySQL. Comprehensively updated to cover PHP 7 and modern best practice,...

    广东省职业技能等级认定证书试卷样题计算机程序员-Web前端开发(四级)A-01.docx

    * 熟悉JavaScript的应用和Best Practice 五、MySQL * 了解MySQL的基本概念和数据类型 * 掌握MySQL的基本操作语句和查询语句 * 熟悉MySQL的索引、视图、存储过程等高级知识 六、PHP * 了解PHP的基本语法和数据...

    阿里云 专有云企业版 V3.6.1 HybridDB for MySQL 用户指南 - 20181105.pdf

    阿里云提供了一份详细的使用指南,帮助用户快速了解 HybridDB for MySQL 的使用方法和best practice。该指南涵盖了 HybridDB for MySQL 的基本使用方法、常见问题解决方法等方面的内容。 troubleshoot 阿里云提供...

    MySQL数据库设置远程访问权限方法总结.pdf

    本文将详细介绍如何设置MySQL数据库的远程访问权限,并提供了一些相关的安全策略和Best Practice。 首先,需要了解MySQL数据库的权限系统。MySQL数据库的权限系统是基于用户和主机的。用户可以是root用户,也可以是...

    PHP & MySQL Novice to Ninja 6th Edition

    on guide to learning all the tools, principles, and techniques needed to build a fully functional application using PHP & MySQL. Comprehensively updated to cover PHP 7 and modern best practice,...

    PHP之安全编程.pdf

    PHP 之安全编程是指在使用 PHP 开发 web 应用程序时,为了保护服务器和用户数据免受不良攻击和恶意活动的影响,需要遵循的一些安全准则和 best practice。下面是从 PHP 之安全编程中提取的一些关键知识点: 一、...

    在线考试系统数据库设计

    在设计数据库时,需要遵守一定的设计原则和规范,例如使用mysql数据库管理系统,遵守mysql的设计规范和best practice。同时,需要根据实际情况选择合适的数据类型和字段长度,以确保数据的正确性和可靠性。 在线...

    开源博客系统SpringBlog.zip

    演示 http://raysmond.com  初学 Spring ,很多写法可能不符合 best practice ,希望有人能给一些建议。网站部署在阿里云 ECS 上,顺便说一下 Java 的网站挺耗内存啊。 标签:SpringBlog

    PHP-MySQL-User-Signup-Login-API:本逐步指南将指导您按照文件夹结构的最佳实践,使用Core PHP + MySQL设置Login + Signup API

    - 使用命名空间(namespace)和自动加载(autoload)简化类的引用。 10. **安全措施**: - 验证输入数据,避免XSS攻击。 - 使用HTTPS加密通信,保护用户数据的隐私。 - 对敏感操作进行授权,如只允许已登录用户...

    藏经阁-百度外卖从 IDC 到云端服务迁移历程.pdf

    阿里云服务迁移best practice 本文档介绍了百度外卖从 IDC 到云端服务迁移的历程,分享了迁移中遇到的挑战、解决方案和迁移效果。本文档将具体介绍百度外卖的迁移背景、迁移目标、解决方案、迁移效果等内容。 迁移...

    阿里云 专有云企业版 V3.6.0 数据管理DMS 技术白皮书 - 20180824.pdf

    该解决方案支持多种数据格式,包括关系型数据库、NoSQL数据库、文件系统等,并提供了数据管理的best practice和技术支持。 7. 安全机制 阿里云专有云企业版数据管理技术提供了多种安全机制,包括数据加密、访问...

    数据库命名公约:数据库命名约定和最佳实践

    本文将深入探讨数据库命名约定和最佳实践,适用于多种常见的数据库系统,包括MySQL、Elasticsearch、MongoDB、PostgreSQL以及MariaDB。 一、通用命名规则 1. 明确性:数据库对象(如表、字段)的名称应清晰明了,...

    Beginning PHP 5.3

    - **Coding Standards:** Explanation of coding standards and best practices in PHP. - **Documentation:** Techniques for documenting code effectively using comments and documentation tools. - **...

Global site tag (gtag.js) - Google Analytics