Friday 31 May 2013

Cluster index

Clustered Index
Pic02.jpg
Pic03.jpg
Pic04.JPG
 Collapse | Copy Code
Select * from student where studid = 103;
Select * from student where studid = 107;
Execution without index will return value for the second query at eights comparison.
Execution of second query with index will return the value at the third comparison. Look below:
  1. Compare 107 vs 103 : Move to right node
  1. Compare 107 vs 106 : Move to right node
  1. Compare 107 vs 107 : Matched, return the record

The primary key created for the StudId column will create a clustered index for the Studid column. A table can have only one clustered index on it.
When creating the clustered index, SQL server 2005 reads the Studid column and forms a Binary tree on it. This binary tree information is then stored separately in the disc. Expand the table Student and then expand theIndexes. You will see the following index created for you when the primary key is created:
With the use of the binary tree, now the search for the student based on the studid decreases the number of comparisons to a large amount. Let us assume that you had entered the following data in the table student:
The index will form the below specified binary tree. Note that for a given parent, there are only one or twoChilds. The left side will always have a lesser value and the right side will always have a greater value when compared to parent. The tree can be constructed in the reverse way also. That is, left side higher and right side lower.
Now let us assume that we had written a query like below:
Execution without index will return value for the first query after third comparison.
Execution of first query with index will return value at first comparison.
If numbers of records are less, you cannot see a different one. Now apply this technique with a Yahoo email user accounts stored in a table called say YahooLogin. Let us assume there are 33 million users around the world that have Yahoo email id and that is stored in the YahooLogin. When a user logs in by giving the user name and password, the comparison required is 1 to 25, with the binary tree that is clustered index.
Look at the above picture and guess yourself how fast you will reach into the level 25. Without Clustered index, the comparison required is 1 to 33 millions.
Got the usage of Clustered index? Let us move to Non-Clustered index.

Wednesday 29 May 2013

How to run perl script i ubuntu ?

In ubuntu environment these are the steps which should follow to run perl script on localhost .

1. install httpd server  on ubuntu by
  sudo apt-get  install apache2 .

2.Go to "File System " .
3.Now start server by giving command "sudo /etc/init.d/apache2 [start/restart] .
4.If started successfully .Go to your browser .it will message "It works " .
5.Now Go to "File System " cd /var/www/ . check is there any folder name as cgi-bin .
6.If there then put your perl file there inside it ,if not then create a cgi-bin.
7.Give the permission to the cgi-bin to "chmod 777 cgi-bin".
8.Now you have to change the default path of Script aliasing.
9.so go to /etc/apache2/site-enabled/
10.There will a file called as 000-default .
11.In that section "Scriptalising" would be there.
12.open 000-default .
13. Instead of "/usr/lib/cgi-bin" change /var/www/cgi-bin/ also at Directory  /var/www/cgi-bin/.
14.Now again restart server as mention in 3 step .
15.run perl program by giving "localhost/cgi-bin/program.pl.

Note:Install perl first.

  

Thursday 9 May 2013

Stay connected: install netbeans on linux environment ..

Stay connected: install netbeans on linux environment ..: 1.Download netbeans for linux  from netbeans.org 2. Extract the downloaded file into your home folder 3. change the persmission [chmod ...

install netbeans on linux environment ..

1.Download netbeans for linux  from netbeans.org

2. Extract the downloaded file into your home folder

3. change the persmission [chmod 777 netbeans-file]

4. run it by ./netbeans name 

Thursday 18 October 2012

why java is more secure

Java's security model is focused on protecting users from programs downloaded from sources across a network. Java programs run in Java Runtime Environment. Java Programs can't take any action outside those boundaries. For example, Programms are prohibited from many activities, including: 

* Reading or writing to the local disk 
* Making a network connection to any host, except the host from which the applet came 
* Creating a new process 
* Loading a new dynamic library and directly calling a native method 

Wednesday 17 October 2012

Delete vs Truncate in SQL

TruncateDelete
TRUNCATE is a DDL commandDELETE is a DML command
TRUNCATE TABLE always locks the table and page but not each rowDELETE statement is executed using a row lock,                                             each row in the table is locked for deletion
Cannot use Where ConditionWe can specify filters in where clause
It Removes all the dataIt deletes specified data if where condition exists.
TRUNCATE TABLE cannot activate a trigger because the operation does not log individual row deletions.Delete activates a trigger because the operation                                are logged individually.
Faster in performance wise, because it is minimally logged in transaction log.Slower than truncate because, it maintain logs for every record
 Drop all object’s statistics and marks like High Water Mark free extents and leave the object really empty with the first extent. zero pages are left in the tablekeeps object’s statistics and all allocated space. After a                       DELETE statement is executed,the table can still contain empty pages.
TRUNCATE TABLE removes the data by deallocating the data pages used to store the table data and records only the page deallocations in the transaction loThe DELETE statement removes rows one at a time                       and records an entry in the transaction log for each deleted row
If the table contains an identity column, the counter for that column is reset to the seed value that is defined for the columnDELETE retain the identity
Restrictions on using Truncate Statement
1. Are referenced by a FOREIGN KEY constraint.
2. Participate in an indexed view.
3. Are published by using transactional replication or merge replication.
Delete works at row level, thus row level constrains apply