These are few mistakes we've come across while working on performance enhancement for an app.
If you are kind of guy who stores GUID in char(36) (weird), use Unique Identifier please, GUID requires 36 bytes of data but if you use UniqueIdentifier type, then we require only 16 bytes of data.
Also, also the N '' prefix, while encoding your Unicode data (to aviod SQL injection etc), if the fields are char or varchar type (check link for the comparison sheet) it will prove costly too.
And its easy to replicate this black hole which leaks your app,
With a test table containing 100,000 rows with a char(36) field containing guids,
The following SQL took 56 ms to run:
SELECT * FROM testtable WHERE guid = N'00008999-A3B3-41FE-BF23-40465CF14147'
Where as the following sql:
SELECT * FROM testtable WHERE guid = '00008999-A3B3-41FE-BF23-40465CF14147'
took 0 ms (less than 1).
Tuesday, September 30, 2008
Monday, May 26, 2008
I am feeling.....
I came across this site quite accidently and 'i feel' this one is really cool, not because of a great UI or features, but appreciate the brains behind this idea.
To know more about what i am talking, land in http://www.wefeelfine.org URL, by the time you are reading this, wefeelfine.org would have sucked this blog's header and made a particle out of it and someone might be reading :)
To know more about what i am talking, land in http://www.wefeelfine.org URL, by the time you are reading this, wefeelfine.org would have sucked this blog's header and made a particle out of it and someone might be reading :)
Tuesday, May 20, 2008
SQL search on float value, using string wild cards
Do convert the float value to bigint and then to nvarchar to search using wild cards and like
e.g
CONVERT(nvarchar, CONVERT(bigint,))
e.g
CONVERT(nvarchar, CONVERT(bigint,
Saturday, April 12, 2008
SQL Server does not exist or access denied.
SQL Server does not exist or access denied. (with SQL 2005 Server)
Troubleshooting steps are as below:
First, telnet 1433
If connection could not be established then
Issue seems to be that you have not enabled the remote connections on the SQL 2005, to do this
1. Go to Surface area COnfiguration from Start - Programs - Microsoft SQL 2005 - Configuration Tools - SQL Server Surface Area Configuration
2. Select Surface area configuration for services and connections
3. Select Remote Connections from Database Engine dropdown list and enable 'Local and Remote Connection'
else if you are able to telnet, check the remote db user privilage you are trying to connect.
Troubleshooting steps are as below:
First, telnet
If connection could not be established then
Issue seems to be that you have not enabled the remote connections on the SQL 2005, to do this
1. Go to Surface area COnfiguration from Start - Programs - Microsoft SQL 2005 - Configuration Tools - SQL Server Surface Area Configuration
2. Select Surface area configuration for services and connections
3. Select Remote Connections from Database Engine dropdown list and enable 'Local and Remote Connection'
else if you are able to telnet, check the remote db user privilage you are trying to connect.
Friday, April 11, 2008
Permission denied to call method XMLHttpRequest.open
Now, this is an age old issue right!!!!
But still i see people asking this question, so its here...
Every web browser puts the security restriction on connections over n/w including our XMLHTTPREQUEST, now this security restriction prevents (the infamous jscript pop up sometimes in IE, wud you like to allow connection to this insercured connection) your scripts in your web application to open the connection to the service in another server but it does allow the call if your required service and application reside in same server (so who wants that!!! rite), and the only workaround is create a proxy in your server (this makes the call and return data )so your scripts can access.
But still i see people asking this question, so its here...
Every web browser puts the security restriction on connections over n/w including our XMLHTTPREQUEST, now this security restriction prevents (the infamous jscript pop up sometimes in IE, wud you like to allow connection to this insercured connection) your scripts in your web application to open the connection to the service in another server but it does allow the call if your required service and application reside in same server (so who wants that!!! rite), and the only workaround is create a proxy in your server (this makes the call and return data )so your scripts can access.
Thursday, April 10, 2008
Why do i get a Download of Specified resource has failed error when using XMLDOM?
Best method to debug this issue is to run the requested url / page separately and check for errors.
Additionaly you may do the following to troubleshoot the issue as this is more like a permissions error. Anonymous IIS account cannot access the resource but you can.
Try following
1. Insert a Response.write(Server.HTMLEncode(xmlHTTP.ResponseText)) command
just after requesting the file on the server. If you get back the correct
data, then it's not a permissions error.
2. Check if requests are reaching the requested page in server.
Additionaly you may do the following to troubleshoot the issue as this is more like a permissions error. Anonymous IIS account cannot access the resource but you can.
Try following
1. Insert a Response.write(Server.HTMLEncode(xmlHTTP.ResponseText)) command
just after requesting the file on the server. If you get back the correct
data, then it's not a permissions error.
2. Check if requests are reaching the requested page in server.
Monday, March 24, 2008
Wednesday, March 19, 2008
Outside technology
I came across this link (http://www.lifehack.org/) accidently and now i visit regularly. This one shares lots of ideas and information and do have pointers for 'productivity and getting things done'. Read and enjoy
Tuesday, February 26, 2008
SQL stuff: 'IS NULL' vs '= NULL'
Check this article on why you should use IS NULL in your query's
http://www.sqlservercentral.com/articles/Basic+Querying/understandingthedifferencebetweenisnull/871/
http://www.sqlservercentral.com/articles/Basic+Querying/understandingthedifferencebetweenisnull/871/
Friday, February 8, 2008
Some SQL Stuff....
Ways you could you limit the number of records returned by SQL query?
There are 2 ways you can do that,
1. set ROWCOUNT to the required number of rec
2. Use TOP in select query
What's the difference, well not much except ROWCOUNT will override TOP if latter value is less. And ROWCOUNT affect subsequent queries.
One of areas ROWCOUNT comes in picture is say you need a Stored Procedure in which you are passing number of records your query must return as a parameter (@paramcnt), here TOP will not be of much use as you cannot have query like 'SELECT TOP @paramcnt FROM ...' but you definitely can put 'set ROWCOUNT @paramcnt', thats my observation......share yours.
There are 2 ways you can do that,
1. set ROWCOUNT to the required number of rec
2. Use TOP in select query
What's the difference, well not much except ROWCOUNT will override TOP if latter value is less. And ROWCOUNT affect subsequent queries.
One of areas ROWCOUNT comes in picture is say you need a Stored Procedure in which you are passing number of records your query must return as a parameter (@paramcnt), here TOP will not be of much use as you cannot have query like 'SELECT TOP @paramcnt FROM ...' but you definitely can put 'set ROWCOUNT @paramcnt', thats my observation......share yours.
Friday, January 25, 2008
Another question....
class A
{
public A()
{
Console.WriteLine("Me A");
}
}
class B : A
{
public B()
{
Console.WriteLine("Me B");
}
}
If an object of class B is created which constructor will fire first?
{
public A()
{
Console.WriteLine("Me A");
}
}
class B : A
{
public B()
{
Console.WriteLine("Me B");
}
}
If an object of class B is created which constructor will fire first?
Thursday, January 17, 2008
Enums - some more basics
Consider enum below
enum test:int
{
a,
b,
c = 5,
d
}
What will the following code display
static void Main(string[] args)
{
Console.WriteLine((int)test.a);
Console.WriteLine((int)test.b);
Console.WriteLine((int)test.c);
Console.WriteLine((int)test.d);
Console.ReadKey();
}
enum test:int
{
a,
b,
c = 5,
d
}
What will the following code display
static void Main(string[] args)
{
Console.WriteLine((int)test.a);
Console.WriteLine((int)test.b);
Console.WriteLine((int)test.c);
Console.WriteLine((int)test.d);
Console.ReadKey();
}
Wednesday, January 16, 2008
Question on hiding instance variable
Consider the class below
class joel
{
public int num = 0;
public void displaynum()
{
int num = 1;
}
public void displaynextnum()
{
num = 2;
}
}
What will below codes print and why?
1. joel j = new joel();
j.displaynum();
Console.WriteLine("Display member " + j.num);
Console.ReadKey();
2. joel j = new joel();
j.displaynextnum();
Console.WriteLine("Display member " + j.num);
Console.ReadKey();
class joel
{
public int num = 0;
public void displaynum()
{
int num = 1;
}
public void displaynextnum()
{
num = 2;
}
}
What will below codes print and why?
1. joel j = new joel();
j.displaynum();
Console.WriteLine("Display member " + j.num);
Console.ReadKey();
2. joel j = new joel();
j.displaynextnum();
Console.WriteLine("Display member " + j.num);
Console.ReadKey();
Constructors and Destructors
1. Could we overload an instance constructor?
2. Does constructors have a return type
3. Could we inherit constructor?
4. When is a destructor invoked?
5. How are destructors invoked?
2. Does constructors have a return type
3. Could we inherit constructor?
4. When is a destructor invoked?
5. How are destructors invoked?
Tuesday, January 15, 2008
Question on exception / try - catch block
Question:
What will be the output for follwing code
try
{
Console.WriteLine("Before Exception");
throw new Exception("Raising exception");
Console.WriteLine("After Exception");
}
catch(Exception e)
{
Console.WriteLine("Inside Catch");
}
finally
{
Console.WriteLine("Inside Finally");
}
Console.WriteLine("Outside Try");
Answer:
Before Exception
Inside Catch
Inside Finally
Outside Try
What will be the output for follwing code
try
{
Console.WriteLine("Before Exception");
throw new Exception("Raising exception");
Console.WriteLine("After Exception");
}
catch(Exception e)
{
Console.WriteLine("Inside Catch");
}
finally
{
Console.WriteLine("Inside Finally");
}
Console.WriteLine("Outside Try");
Answer:
Before Exception
Inside Catch
Inside Finally
Outside Try
Friday, January 11, 2008
.NET basics revisited......continued
Now question below is from a written test / interview
Question:
public void MergeSort(List list, int low, int high)
{
int temp;
if (low == high)
{
return;
}
if (high - low == 1)
{
if (list[low] > list[high])
{
temp = list[low];
list[low] = list[high];
list[high] = temp;
}
}
else
{
int mid = high + low / 2;
MergeSort(list, low, mid);
MergeSort(list, mid + 1, high);
}
}
a. run time exception
b. Will completely sort the list
c. Will partially sort the list
Answer: Stackoverflow exception, recursive call is going for an infinite loop.....
also please do comment if any other answers
Question:
public void MergeSort(List list, int low, int high)
{
int temp;
if (low == high)
{
return;
}
if (high - low == 1)
{
if (list[low] > list[high])
{
temp = list[low];
list[low] = list[high];
list[high] = temp;
}
}
else
{
int mid = high + low / 2;
MergeSort(list, low, mid);
MergeSort(list, mid + 1, high);
}
}
a. run time exception
b. Will completely sort the list
c. Will partially sort the list
Answer: Stackoverflow exception, recursive call is going for an infinite loop.....
also please do comment if any other answers
Thursday, January 10, 2008
.NET basics revisited
I am on 'bench' these days.....well if thats not in your dictionary - 'its that condition of software engineer when he/she is not assigned to any projects / tasks'.
So thought of checking out tips, questions, tweaks, forums,interview questions etc in .NET....my next posts will be ones i have come across...so look out :)
Question: Which one among the following is illegal
a. Base b = new Derived();
b. Dervied b = new Base();
Where Derived is class inherited from Base...
Answer: b, now u can try and tell me
Question :
class A
{
public virtual void f()
{
Console.WriteLine("A.F");
}
}
class B : A
{
public override void f()
{
Console.WriteLine("B.F");
}
}
class C : B
{
new public virtual void f()
{
Console.WriteLine("C.F");
}
}
class D : C
{
public override void f()
{
Console.WriteLine("D.F");
}
}
class Program
{
static void Main(string[] args)
{
D d = new D();
A a = d;
B b = d;
C c = d;
a.f();
b.f();
c.f();
d.f();
}
}
What will this print
Answer: B.F B.F D.F D.F
If derived class overrides a method base class, objects of the derived class will call that method rather than the base class method.
So thought of checking out tips, questions, tweaks, forums,interview questions etc in .NET....my next posts will be ones i have come across...so look out :)
Question: Which one among the following is illegal
a. Base b = new Derived();
b. Dervied b = new Base();
Where Derived is class inherited from Base...
Answer: b, now u can try and tell me
Question :
class A
{
public virtual void f()
{
Console.WriteLine("A.F");
}
}
class B : A
{
public override void f()
{
Console.WriteLine("B.F");
}
}
class C : B
{
new public virtual void f()
{
Console.WriteLine("C.F");
}
}
class D : C
{
public override void f()
{
Console.WriteLine("D.F");
}
}
class Program
{
static void Main(string[] args)
{
D d = new D();
A a = d;
B b = d;
C c = d;
a.f();
b.f();
c.f();
d.f();
}
}
What will this print
Answer: B.F B.F D.F D.F
If derived class overrides a method base class, objects of the derived class will call that method rather than the base class method.
Subscribe to:
Posts (Atom)