<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    2009年12月14日

    c++ difference from java
    1. take charge of object management , negotiate ownershiop ,use scoped_ptr,
       not to transfer other's ownership
    2. use c++ template to express seperation corncern ,such as (static)polymorphy and policy
    3. disable copy constructor and assign operator by yourself
    4. polymorphy by pointer
    5. 使用 template ,macro 取得類似動(dòng)態(tài)語言的能力
    6. 偏好無狀態(tài)的 函數(shù)
    posted @ 2010-02-03 11:43 西津渡 閱讀(260) | 評論 (0)編輯 收藏
     
        只有注冊用戶登錄后才能閱讀該文。閱讀全文
    posted @ 2010-01-15 12:22 西津渡 閱讀(100) | 評論 (0)編輯 收藏
     

    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/

    posted @ 2010-01-05 13:38 西津渡 閱讀(388) | 評論 (0)編輯 收藏
     
        只有注冊用戶登錄后才能閱讀該文。閱讀全文
    posted @ 2010-01-04 15:11 西津渡 閱讀(77) | 評論 (0)編輯 收藏
     

    從時(shí)序圖中可以看到,createNewIO()就是新建了一個(gè)com.mysql.jdbc.MysqlIO,利用 com.mysql.jdbc.StandardSocketFactory來創(chuàng)建一個(gè)socket。然后就由這個(gè)mySqlIO來與MySql服務(wù)器進(jìn)行握手(doHandshake()),這個(gè)doHandshake主要用來初始化與Mysql server的連接,負(fù)責(zé)登陸服務(wù)器和處理連接錯(cuò)誤。在其中會分析所連接的mysql server的版本,根據(jù)不同的版本以及是否使用SSL加密數(shù)據(jù)都有不同的處理方式,并把要傳輸給數(shù)據(jù)庫server的數(shù)據(jù)都放在一個(gè)叫做packet的 buffer中,調(diào)用send()方法往outputStream中寫入要發(fā)送的數(shù)據(jù)。


    useServerPreparedStmts置為true的話,mysql驅(qū)動(dòng)可以通過PreparedStatement的子類ServerPreparedStatement來實(shí)現(xiàn)真正的PreparedStatement的功能




    第一位表示數(shù)據(jù)包的開始位置,就是數(shù)據(jù)存放的起始位置,一般都設(shè)置為0,就是從第一個(gè)位置開始。第二和第三個(gè)字節(jié)標(biāo)識了這個(gè)數(shù)據(jù)包的大小,注意的是,這個(gè)大小是出去標(biāo)識的4個(gè)字節(jié)的大小,對于非最后一個(gè)數(shù)據(jù)包來說,這個(gè)大小都是一樣的,就是splitSize,也就是maxThreeBytes,它的值是 255 * 255 * 255。
    最后一個(gè)字節(jié)中存放的就是數(shù)據(jù)包的編號了,從0開始遞增。
    在標(biāo)識位設(shè)置完畢之后,就可以把255 * 255 * 255大小的數(shù)據(jù)從我們準(zhǔn)備好的待發(fā)送數(shù)據(jù)包中copy出來了,注意,前4位已經(jīng)是標(biāo)識位了,所以應(yīng)該從第五個(gè)位置開始copy數(shù)據(jù)

     # packetToSend = compressPacket(headerPacket, HEADER_LENGTH,    
    #                 splitSize, HEADER_LENGTH); 

    LoadBalancingConnectionProxy
    package java.lang.reflect 。 proxy .


    http://developer.51cto.com/art/200907/137823.htm

    http://dev.mysql.com/doc/refman/5.1/en/connector-j-reference-implementation-notes.html

    PreparedStatements are implemented by the driver, as MySQL does not have a prepared statement feature. Because of this, the driver does not implement getParameterMetaData() or getMetaData() as it would require the driver to have a complete SQL parser in the client.

    Starting with version 3.1.0 MySQL Connector/J, server-side prepared statements and binary-encoded result sets are used when the server supports them.


    但這是不是說PreparedStatement沒用呢?不是的,PreparedStatement有其他的好處:
    1.代碼的可讀性和可維護(hù)性
    2.最重要的一點(diǎn)是極大地提高了安全性,可以防止SQL注入

    然后我又看了一些網(wǎng)上其他人的經(jīng)驗(yàn),基本和我的判斷一致,有兩點(diǎn)要特別提請大家注意:

    1.并不是說PreparedStatement在所有的DB上都不會提高效率,PreparedStatement需要服務(wù)器端的支持,比如在 Oracle上就會有顯著效果。上面說的測試都是在MySQL上測試的,我找到了一個(gè)MySQL架構(gòu)師的帖子,比較明確地說明了MySQL不支持 PreparedStatement。

    2.即便PreparedStatement不能提高性能,在少數(shù)使用時(shí)甚至?xí)档托剩匀粦?yīng)該使用PreparedStatement!因?yàn)槠渌? 處實(shí)在是太大了!當(dāng)然,當(dāng)SQL查詢比較復(fù)雜時(shí),可能PreparedStatement好處會更大,只是我沒有測試,不敢肯定。

    3.既然PreparedStatement不能提高效率,那PreparedStatement Pool也就沒有必要了。但可以看到每次新建Connection的開銷實(shí)在很大,因此Connection Pool絕對必要。



    posted @ 2009-12-30 12:41 西津渡 閱讀(381) | 評論 (0)編輯 收藏
     
    download ,annatation and tools 兩個(gè)項(xiàng)目。
    添加相關(guān)的 jar.

    <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="master.classpath" />

    <target name="create_table">

    <hibernatetool destdir="${script.dir}">
        <annotationconfiguration configurationfile="src/hibernate.cfg.xml" />
        <hbm2ddl export="false" create="true" delimiter=";" format="true" outputfilename="create-tables.sql" />
    </hibernatetool>

    </target>

    <!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

    <hibernate-configuration>
        <session-factory name="logi">
            <property name="show_sql">true</property>
            <mapping class="com.tt.logi.target.Target"/>
       
        </session-factory>
    </hibernate-configuration>

    import java.io.Serializable;

    import javax.persistence.Basic;
    import javax.persistence.Entity;
    import javax.persistence.Id;

    @Entity
    public class Target implements Serializable{
       
        private Long id;
        private String name;
        @Id
        public Long getId() {
            return id;
        }
        public void setId(Long id) {
            this.id = id;
        }
        @Basic
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
       
       
       

    posted @ 2009-12-14 19:04 西津渡 閱讀(99) | 評論 (0)編輯 收藏
     
    wget ftp://ftp.jaist.ac.jp/pub/mysql/Downloads/MySQL-5.1/mysql-5.1.41.tar.gz
    tar -xzf



    ./configure --prefix=/usr/local/mysql51m --without-debug  --enable-local-infile --enable-assembler --enable-thread-safe-client --with-plugins=all

    make
    su -
    make install


    groupadd mysql
    useradd -g mysql mysql


    bin/mysql_install_db --user=mysql  --datadir=/var/lib/mysql51m/data

    chown -R mysql /var/lib/mysql51m/
    chgrp -R mysql /var/lib/mysql51m/


    cp share/mysql/my-innodb-heavy-4G.cnf my.cnf
    vi my.cnf

    datadir = /var/lib/mysql51m/data

    .bin/mysqld_safe --defaults-file=/usr/local/mysql51m/my.cnf &

    bin/mysql  --defaults-file=my.cnf -uroot

    ./mysqladmin -u root password ‘humber’
    grant all on *.* to root@% identified by 'humber'

    default-character-set=utf8
    init_connect='SET NAMES utf8'
    default-storage-engine = INNODB

    posted @ 2009-12-14 14:44 西津渡 閱讀(117) | 評論 (0)編輯 收藏
     
    主站蜘蛛池模板: 一二三四在线播放免费观看中文版视频| 日韩在线视频免费看| 亚洲综合图片小说区热久久| 在线观看免费高清视频| 精品无码一级毛片免费视频观看| 亚洲精品国产成人99久久| 色吊丝最新永久免费观看网站| 中国人免费观看高清在线观看二区 | 国产特黄一级一片免费 | 伊伊人成亚洲综合人网7777| 4虎1515hh永久免费| 特级毛片免费播放| 亚洲国产综合精品| 亚洲人成网77777色在线播放| 成人无遮挡裸免费视频在线观看| jizz18免费视频| 亚洲熟伦熟女专区hd高清| 亚洲国产另类久久久精品黑人| 久久这里只有精品国产免费10| 在线免费观看h片| 亚洲国产欧美一区二区三区| 亚洲精品国产成人专区| 亚洲精品国精品久久99热| 天天看免费高清影视| 在线观看的免费网站无遮挡| 国产成人高清精品免费观看| 亚洲一卡2卡3卡4卡5卡6卡| 亚洲午夜视频在线观看| 亚洲一区二区三区免费| 国产精品二区三区免费播放心| 69视频在线观看免费| a级毛片免费全部播放无码| 美女视频黄频a免费| 99999久久久久久亚洲| 亚洲视频中文字幕| 亚洲精品国产精品乱码不99| 免费一级特黄特色大片在线观看| 好先生在线观看免费播放| 中文字幕天天躁日日躁狠狠躁免费| 一区二区三区在线免费观看视频 | 亚洲第一成年人网站|