Mysql High Performance Datatypes/Indexing

Choosing Optimal Data Types

  • Smaller is usually better.
  • Simple is good. For example, integers are cheaper to compare than characters, because character sets and collations (sorting rules) make character comparisons compli- cated.
  • Avoid NULL if possible.
VARCHAR and CHAR types
BLOB and TEXT types
Using ENUM instead of a string type
DATETIME and TIMESTAMP types
Bit-Packed Data Types

A Mixture of Normalized and Denormalized

The most common way to denormalize data is to duplicate, or cache, selected columns from one table in another table. In MySQL 5.0 and newer, you can use triggers to update the cached values, which makes the implementation easier.

Cache and Summary Tables

Materialized Views
Counter Tables

Types of Indexes

Pending...

Transcation Management in Java

Recently I encountered a great number of topics with transcation management whatever in a interview or web application.

  • How to handle read-write splitting?
  • How to handle transcation in distributed system, i.e. distributed transcation?

There are lots of Java solution in the wild, e.g. Spring transaction, Java Transaction API (JTA), JDBC, Hibernate, Java Persistence API (JPA), and Java Data Objects (JDO).

Pending...

References:

  1. http://docs.spring.io/spring-framework/docs/current/spring-framework-reference/html/transaction.html

Learning Unit Test in Java

The post aims to share my some thoughts of how to learn unit test in java, I will give a little bit more insights on how I am thinking on this. Hope this will bring you more inspirations.

There are two popular testing philosophys a.k.a TDD(Test-Driven Development) & BDD(Behaviour-Driven Development), I started to search some good frameworks with BDD. I knew about BDD from javascipt testing framework, e.g. Mocha, Jasmine, so I am pretty eager to know whether there are any popular BDD frameworks in Java perspective. After reading couples of posts, JBehave and Cucumber are relatively welcomed in the community. Cucumber works with Ruby, Java, .NET, Flex or web applications written in any language. It has been translated to over 40 spoken languages, and gains more stars on github. Moreiver, TDD is much more well-known for most Java developer like JUnit, TestNG etc.

Read More

Setting Github Pages

There are only two steps to setup your personal blog with your own domain.

  • Create a CNAME file under the root of your repos(e.g. https://github.com/sicongtang/sicongtang.github.io/blob/master/CNAME), in hexo or octopress blog system, just create a CNAME file under source folder. This will automatically deploy CNAME file to your repository's root directory.

  • Then you need to configure a custom subdomain with your DNS provider. Creating two A records helps you to use custom apex domains. In addition, if you configure both an apex domain (e.g. sicongtang.me) and a matching www subdomain (e.g. www.sicongtang.me), GitHub's servers will automatically create redirects between the two.

Read More