Friday, March 18, 2011

Indexing in Database


indexes are used to speed up the data retrieving queries known as select queries. Indexes are created on a per column basis. If you have a table with the columns: name, age, birthday and employeeID and want to create an index to speed up how long it takes to find employeeID values in your queries, then you would need to create an index for employeeID. When you create this index, MySQL will build a lookup index where employeeID specific queries can be run quickly. However, the where clause based on the  name, age and birthday queries would not be any faster.

Indexes are something extra that you can enable on your MySQL tables to increase performance,but they do have some downsides. When you create a new index MySQL builds a separate block of information that needs to be updated every time there are changes made to the table. This means that if you are constantly updating, inserting and removing entries in your table this could have a negative impact on performance.


Advantages 
  • Indexes speed up the data retrieving based on where and order by clauses
Disadavantages
  •  Indexes slow down inserts , update and deleted, so you want to use them carefully on columns that are FREQUENTLY changed.
  •  Creating an index requires an additional storage space . this space is occupied by the look-up index and it keep a track of modification(insert/delete/update) records those were done to the related column/field. therefore too many indexes can increase the database size and the file size unnecessarily.

create mysql index on new table

 If you are creating a new MySQL table you can specify a column to index by using the INDEX term as we have below. We have created two fields: name and employeeID (index).

CREATE TABLE employee (
 name VARCHAR(50), 
 employeeID INT, INDEX (employeeID)
)
 
 
create mysql index on existing table

CREATE INDEX id_index ON employee(employeeID)
 
Hope this will helpful for you!

regards
Chathuranga Tennakoon
chathuranga.t@mail.com

Saturday, March 12, 2011

Enable HTTPS in Apache Tomcat server

I have assumed that you have properly installed Apache tomcat server and it is perfectly running on HTTP protocol.if you don't know how to install Apache tomcat , you can refer my previous blog post on  Installing Apache Tomcat .In order to configure HTTPS support in the tomcat server, you are required to folllow the steps given below.

1. it is required to have a self-signed server certificate for https. therefore you have to use keytool utility to generate such certificate for your tomcat server. type the keytool command in the command prompy \t to check whether the key tool utility is working.

C:\> keytool

if it is working, it should display a list of commands that are owned to the keytool utility. otherwise it will show you an error message indicating that keytool is not recognized as an internal or external command. if you get such error message, the reason is exactly you have not set JDK/JRE classpath in your command prompt. in such case, it is required to append C:\Program Files\Java\jdk1.6.0\bin (in my case) to the end of the path environment variable. then it will run the keytool utility properly.

Environment Variable
path = C:\Program Files\Java\jdk1.6.0\bin

2. then type the following command in the command prompt for generating the server certificate.

keytool -genkeypair -alias tomcat -keyalg RSA -keysize 1024 -dname "CN=localhost, OU=Organization, O=Company Name, L=City, S=State, C=US"
-validity 365 -keystore keystore

Enter keystore password: <enter a new password here>

 
Enter key password for <tomcat>

        (RETURN if same as keystore password): <just hit enter here>


The password you enter in the first password prompt will be the password for the keystore where your server certificate is stored.

3.Next, edit your Tomcat's conf/server.xml to enable the HTTPS connector. Look for a connector that looks like this:

    <!--
    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->


by default, this has been commented and you are required to remove the comment.

Wednesday, March 9, 2011

Installing Apache Maven in Windows Environment

Apache Maven is a java based project build and automation tool. since it is java based, it is required to have a valid JDK version prior to proceed with the Maven installation.Apache maven can be downloaded through Apache maven official website.  Here i am downloading and installing the Apache maven 3.0.3 version.  please follow the instructions given below for installing Maven in your windows based development environment.

 1. extract the downloaded ZIP file and copy the extracted directory (In my case, apache-maven-3.0.3 directory  ) to the C:\Program Files

2. then create the following environment variables

  M2_HOME ( values refers to the maven home directory e.g:-  C:\Program Files\apache-maven-3.0.3 )
  M2 ( value refers to the maven binary directory e.g:- C:\Program Files\apache-maven-3.0.3\bin )
  path (if this variable already exists, please append this value to the end - %M2%)

 3. now the maven is installed to your computer and you can check it through the command line as follows.

   mvn --version


 hope this will helpful for you !

regards
Chathuranga Tennakoon
chathuranga.t@gmail.com