Thursday, January 17, 2008

Definitions related with SQL Server

DML

DML is abbreviation of Data Manipulation Language. It is used to retrieve, store, modify, delete, insert and update data in database.

Examples: SELECT, UPDATE, INSERT, DELETE

DDL

DDL is abbreviation of Data Definition Language. It is used to create and modify the structure of database objects in database.

Examples: CREATE, ALTER, DROP statements

DCL

DCL is abbreviation of Data Control Language. It is used to create roles, permissions, and referential integrity as well it is used to control access to database by securing it.

Examples: GRANT, REVOKE statements

TCL

TCL is abbreviation of Transactional Control Language. It is used to manage different transactions occurring within a database.

Monday, January 07, 2008

Fun with WWW::Mechanize

WWW::Mechanize is really a very handy module if you want to automate web page related tasks. Following PERL script downloads the Perl Cook Book pages in a directory. You can put this Perl script in a scheduler and all pages will be collected in few days.

use strict;
use WWW::Mechanize;

my $mech = WWW::Mechanize->new();
my $ouputDir = 'E:\work\documents\PerlCookBook';
my @urls = (
'http://www.perl.com/cookbook/perlckbk2/solution.csp?day=1',
'http://www.perl.com/cookbook/perlckbk2/solution.csp?day=2',
'http://www.perl.com/cookbook/perlckbk2/solution.csp?day=3',
'http://www.perl.com/cookbook/perlckbk2/solution.csp?day=4',
'http://www.perl.com/cookbook/perlckbk2/solution.csp?day=5'
);

foreach my $url (@urls) {
GetPage($url);
}

sub GetPage {
my $url = $_[0];
$mech->get($url);
if ( $mech->success() ) {
my $content = $mech->content();
if ( $content =~ /\<h2 class="head1"\>(.*)?\<\/h2>/ ) {
my $title = $1;

#$title =~ s/\s+//g;
my $filePath = $ouputDir . "\\PCB_" . $title . ".html";
if ( !-e $filePath ) {
open( WR, ">$filePath" ) or die "Can't create file $filePath\n";
print WR $content;
close WR;
print "File was created successfully\n";
}
else {
print "File already exists\n.";
}
}
}
else {
print "Reqeust was not successful\n";
}
}

Friday, January 04, 2008

Recompilation in SQL Server 2005

Before executing SQL statement, SQL server checks for the validity and correctness of the query and generates the execution plan if it's not all already available. No need to say compilation is very CPU intensive process. Before executing the already compiled SQL statement, SQL server perform several other checks and if any of these checks fails, SQL server perform again compilation of SQL statement. Such compilations are known as recompilations. Following are some reasons for recompilation:

  1. Schema change
  2. Statistics change
  3. Deferred compile
  4. SET option change
  5. Temporary table change
  6. Stored procedure created with RECOMPILE query hint or OPTION(RECOMPILE)

In SQL Server 2000, if you need to recompile a portion of stored procedure, you need to compile the whole stored procedure, however in SQL Server 2005, you can perform recompilation at statement level. Less recompilation means less CPU consumption and less contention.

For more information, see Identifying Recompilation

Wednesday, January 02, 2008

Considerations while designing own types

Though Value Types are created on stack and in some situation gives better performance as compare to Reference Types, we should not tempt with choosing Value Type for every situation. General misconception is that if we are not having complex functionality, we should choose Value Type. We should not forget that size of instance also does matter in copy operation. In functions, Value Types are passed by copying the instance as a parameter. Similarly if function is returning Value Type, that is also copied in caller function's memory space. We can make our type as Value Type in following situations:

  1. Type has no members that modify any of the type's instance field. In other words, type is immutable.
  2. Type should not lie in inheritance chain. That means, it should inherit from any other type and also any other type should derived from it.
  3. Instances of the type are small in size (16-20 bytes or less)
  4. Instances of the type are large (greater than 20 bytes) and are not passed as argument or return value in functions.

Most promising technologies in 2008

Welcome 2008. I see following technologies which can take a big leap in 2008:

  1. Microsoft Silverlight framework – facilitates you to run a desktop like application in Internet Explorer.
  2. Ultra Mobile PC (UMPC)- Size of a your hardback book, weight less than a Kg, no hard drive, only flash memory of approx 4 Gb. Visit Asus EEE
  3. ADSL2+: Broadband speed up to 24 Mbps (Of course not in India J)
  4. IPTV: Progress in this field was hampered in past. But now with the increase in broadband speed, this technology is ready to take off.