AUGUSTEN TECHNICAL

FRESHERS SHINE

Pages

Thursday, 1 January 2015

TEN Most Important Technology Stories of 2014.



This year gave us plenty of headlines for the tech industry, both positive and negative. From the introduction of new devices like the iPhone 6 to enormous  data breaches at major companies, 2014 showed how technological developments are impacting all corners of the world. As we reflect on the year gone by, we've chosen what we think are the 10 most important technology stories of 2014.

Unprecedented Data Breaches and Cybercrime

This was the year that hacking graduated from nuisance to an act of war. In addition to significant data breaches at companies like Dairy Queen, JP Morgan, and Apple, several government agencies were also the victims of serious cyberattacks, including the U.S. Department of State, the U.S. Postal Service, and the National Oceanic and Atmospheric Administration (NOAA).

More worrisome, however, is the fact that several of the attacks seem to be coming from state actors. The NOAA hack is thought to be the work of the Chinese government, while the Russian government is suspected of being behind a breach of White House computer systems. The recent attack on Sony Pictures Entertainment, which proved to be the costliest data breach in history, is believed to have been perpetrated by the North Korean government. However, some security experts disagree and are pinning the blame on Sony insiders.

Cloud Computing Goes Mainstream
Tech companies moved into the cloud in a big way this year. Several companies debuted new cloud services, including Salesforce, which introduced a centralized file sharing service; Microsoft and Accenture teaming up on Microsoft Azure, a hybrid cloud platform; and Dell debuting its new cloud service marketplace.

It also fueled a ton of M&A (merger and acquisition) activity, with major tech firms all lining up to get their hands on hot cloud technology. EMC bought three enterprise hybrid cloud startups -- in addition to Cisco’s stake in VCE -- in October, while Google, Adobe and IBM all made cloud-based acquisitions of their own.

Big Data
IBM was also a major player in big data in 2014, leading the charge to see data analytics brought to more applications. It launched a predictive polling service in collaboration with researchers at Columbia University, and made a big push to expand its Watson artificial intelligence client base with several new global clients.

Meanwhile, the National Institute of Health funded a major new effort to make its biomedical data sets available to researchers all over the world; Pandora offered musicians access to data on their fan bases; Cisco offered to help local governments make their cities smarter; and the LAPD increased its use of big data analytics to more efficiently deploy its officers.

Internet of Things

The Internet of Things (IoT), the term applied to the effort to connect everyday objects to the Internet, also got lots of love in 2014, with several new consortiums formed to help speed its development. Cisco said it would invest $150 million in its IoT efforts; Intel introduced its new IoT Platform; and New York startup LittleBit launched a module to allow DIYers to connect their own devices to the Internet. Microsoft joined the AllSeen Alliance while Samsung, Intel and Dell created the Open Interconnect Consortium to develop IoT interconnection protocols.

Wearable Tech

Lots of companies brought wearable devices to the market this year. Although the big headline might have been Apple’s introduction of its Apple Watch at its keynote address in September (but not expected to go on sale until early 2015), several other players made waves with their own products, including new fitness trackers from Fitbit and Microsoft, and a high-fashion wrist accessory from Intel.

Bigger Phones

Phones seemed to have increased in size this year. The iPhone 6 Plus is the largest handset Apple has ever produced by a long shot, coming in with a 5.5-inch screen, surpassing even the 4.7-inch screen of the iPhone 6. Samsung brought its own behemoth to market with the Galaxy Note Edge, a 5.6-inch monster of a phone. Sony and Motorola both introduced models of that passed the 5-inch mark.

Bad Apple


Not everything was positive for Apple this year, though, as the company had its own share of problems. Larger may not have been better for the company’s handsets. The larger size of the iPhone 6 Plus seemed to contribute to it warping and bending under even the slightest pressure -- leading to plenty of 'Bendgate' headlines shortly after the 6 Plus came to market.

A hack of Apple's iCloud ended with the release of dozens of nude photos of celebrities, damaging Apple’s reputation for security in a high-profile case. Meanwhile, the long-awaited up date to its desktop OS, Yosemite, got off to an inauspicious start with several connectivity bugs plaguing the new system.

Gagging on Lollipop

But Apple was far from the only company suffering from buggy OS updates. Android users had their own share of problems as the Android update known as Lollipop led to major problems for users of many Android devices, including RAM management and app compatibility issues. Many of our readers complained that the update made their devices almost unusable, with apps crashing and bugs making multitasking impossible.

Alibaba IPO

Meanwhile, if there was any lingering doubt about the importance of technology companies in the business world, Alibaba’s IPO on the New York Stock Exchange put them to rest. The Chinese e-commerce company enjoyed the largest public offering in history, raising $25 billion in September.

Ice Bucket Challenge
Bucking a trend of stories outlining the many ways social media can be used for evil, the popularity of the Ice Bucket Challenge proved that, occasionally, it can also help support important causes. The meme, which involved people taking videos of themselves pouring a bucket of ice water over their heads to raise money and awareness for Lou Gehrig’s Disease, exploded on social media over the summer. The popular meme helped raise $97 million dollars for the ALS Association, and helped pour cold water on the idea that social media is a complete waste of time.

Friday, 7 November 2014

How to troubleshoot SQL Server performance issues



To troubleshoot performance issues, you must complete a series of steps to isolate and determine the cause of the problem. Possible causes include:
Blocking
System resource contention
Application design problems
Queries or stored procedures that have long execution times

Identifying these causes is typically very time consuming, and you may spend several days evaluating the collected information. The complexity of the performance analysis is not specific to a particular database product or operating system. All applications are subject to performance constraints because of resource, design, or usage factors.



To help identify and troubleshoot the problem, collect the following information at the same time and have the output readily available before you contact Microsoft Product Support Services (PSS):
Blocker script output
SQL Profiler trace log
SQL Server Performance Monitor log

Note If you do not collect this information when the performance problem occurs, you may have to gather all the information again. This can delay the troubleshooting process.

After the problem occurs, collect the following information and have it available:
sqldiag report
Microsoft Windows NT System and Application Event logs

In most scenarios, PSS requires this information to understand the environment and the nature of the performance issue. If any part of this information is not available, the troubleshooting process may be prolonged and identifying the performance issue may be delayed.

Even if you are currently not experiencing any performance issues, Microsoft recommends that you implement this process. If a performance issue occurs, you can capture the required information as soon as possible. Additionally, if you capture a baseline SQL Profiler log, SQL Server Performance Monitor log, and blocker script when the application is performing as expected, you can use that information for comparison when the application does not perform as expected.

If you gather this information in a high traffic SQL Server environment, you may experience some performance degradation. However, you must have this information to identify the cause of the problem and for troubleshooting purposes. The SQL Profiler trace has the most impact on performance. If the performance is severely degraded, you can customize the SQL Profiler trace by reducing the types of events that it captures. Limiting the SQL Profiler trace should provide some improvement. If you have questions or problems setting up and collecting the information, contact PSS.


Blocker script output

The blocker script is critical for identifying blocking scenarios. However, you can use the output from the script to troubleshoot performance problems even when blocking is not an issue. This output also helps to determine if queries are waiting on resources, such as file I/O, or if transactions are not being committed or rolled back as expected.



SQL Profiler trace log

The SQL Profiler trace captures the activity on the computer running SQL Server. You can use this information to identify slow running queries and non-optimal execution plans. Additionally, SQL Profiler documents the series of events that occur before the performance problem and helps to identify its cause.



Note If you have a SQL Profiler trace of a large workload, you can use the Index Tuning Wizard. The Index Tuning Wizard uses the SQL Server query optimizer to determine the optimal set of indexes for the specified queries. The Index Tuning Wizard is a very efficient tool to determine if the correct indexes exist in your database. By implementing the indexes that the wizard suggests, you may be able to increase the performance of your application.

For more information about how to use the Index Tuning Wizard, see the "Index Tuning Wizard" topic in SQL Server Books Online.


SQL Server Performance Monitor log

SQL Server is typically affected by the following bottlenecks:
CPU
Memory
File I/O
Locking, blocking, or deadlocking

You can use SQL Server Performance Monitor to identify how these potential bottlenecks may affect SQL Server. Additionally, you can use this log to identify when an external process is heavily using the computer running SQL Server and negatively impacting SQL Server performance.

Before you start SQL Server Performance Monitor, make sure that the disk counters are on. To do so, run diskperf from a command prompt. If the disk counters are not on, run diskperf -y and then restart the computer.

When you create a SQL Server Performance Monitor log, collect the following information:
Paging file
Process
Processor
All SQL Server counters
Memory
Threads
Logical disk
Physical disk
System

Note The default interval of 15 seconds should enough time to monitor the server; however, for some timing issues, you may have to reduce the time interval for collecting data.



Note For more information about monitoring performance in SQL Server 2005, see the "Monitoring and Tuning for Performance" topic in SQL Server 2005 Books Online.

sqldiag utility

The sqldiag utility is provided with SQL Server. It collects valuable information about the configuration of the computer running SQL Server, the operating system, and the information that is reported to the SQL Server error logs. For information about how to use the sqldiag utility, see the "sqldiag Utility " topic in SQL Server Books Online.




Note In SQL Server 2005, the SQLdiag utility has changed significantly. The command line arguments for this utility are not compatible with SQL Server 2000. This utility may be changed, and applications or scripts that rely on its command line arguments or behavior may not work correctly in future releases. For more information, see the "SQLdiag Utility" topic in SQL Server 2005 Books Online.

Microsoft Windows NT System and Application Event logs

You can use the Windows NT system and application event logs to identify issues that you cannot see in other data. These logs help provide a complete view of server activity and provide a more complete understanding of the environment.


Where to save these files

The following Microsoft File Exchange FTP server permits you to send and receive files to and from PSS engineers:
ftp://ftppss.microsoft.com



For more information, read the instructions that are provided on the Microsoft File Exchange FTP Web site.

Thursday, 30 October 2014

JAVA UPADATED FEATURES


java 1.4 feature
   Assertions
- Used to check assumptions to guarantee the application always executes complying specifications
- Used as a debugging tool during dev and testing
- Added in 1.4
- Assertions ensure "correctness" of application as per business rules where as Exception Handling ensures "Robustness"
- Also known as "Pre-contracting"
- Syntax
- assert condition;

Eg: assert value == 5;

- assert condition : message;

Eg: assert (value == 5) : "Value should be 5";

To enable asserstions
java -enableassertions AssertionExample
or
java -ea AssertionExample

To disable asserstions
java -da AssertionExample
or
java -disableassertions AssertionExample

Note: Assertions are by default disabled.


 Java5 features

 Autoboxing
   - Converting primitive to its respective wrapper class object is
     called autoboxing.

     Eg:

int i = 98;

Integer obj = i;//Autoboxing
Integer obj = new Integer(i);//Before java5.

Unboxing
   - Converting wrapper class object its respective primitive value
     is called unboxing.

Eg:
Integer obj = 98;

int i = obj.intValue();//Before java5

int i = obj;//unboxing.

Note: If the Integer object is NULL and if we apply unboxing
      then we will get NPE at runtime.

Static imports
  - Static members of a class can be imported into another class
    by using static imports
    Eg:
import static com.xyz.Utility.m1;
import static com.xyz.Utility.bankName;

      Note: Here above import statements will imports static members
           "m1" and "bankName".

      Note: If we want to import all the static members of a class
            at a time then import with *

    Eg:
import static com.xyz.Utility.*;

Covariant Return type
 - An overridden method in a sub class can have return type of as
   same as return type of super class method or sub-class type of
   super class method return type. This is is called covariant
   return types.

Eg:
class A{

}
class B extends A{
}

class Super{
public A getA(){};
}

class Sub extends Super{
public B getA(){};
}

     Note: here overridden method getA() in class "Sub" can have
           return type as B because the B is sub type of A.

Formatted output
 - There is a method format() is added to PrintStream to produce
   formatted output like in 'C'

   Eg:
System.out.format("I value = %d and F value = %f",i,f);

Varargs( Variable arguments)
  - By using var-args we can pass 0 or more paramters to a method.
  - All these parameters are going to bind to a single arugment
    of a method

Eg:

public int add(int i, int ...j){
}

1. Here "j" is variable arument in the add method. It will
   accept 0 or more integers.
2. var-args should be prefixed with 3 dots i.e. "..."
3. var-args must be the last argument in a method
3. Only one var-arg is allowed for a method.

For each loop/ Enhanced for loop

- By using for each or ehanced for loop we can iterate through the
  array of elements or collections of elements with out using
  loop counter or iterator.

Eg:

String arr[] = {"abc","xyz","hello","lakven"};

for(String value : arr){
System.out.println("value == "+value);
}

ArrayList<String> al = new ArrayList<String>();

al.add("RAm");
al.add("Amod");
al.add("Yogesh");
al.add("Visu");

for(String value : al){
System.out.println("value == "+value);
}


StringBuilder
 - The behavior of this class is same as StringBuffer
 - All methods in this class are NOT synchronized where as in
   StringBuffer methods are synchronized.
 - This class object is not thread-safe.


Scanner
 - This class is used read the specific data types for an
   input Stream.

Enums
  - enums are used to specify list of constants
  - In C programming enums are String representation of int constants.
  - In java enums are public static final object of enum type
  - Java enums are sub classes of java.lang.Enum
  - methods, variables, constructors can be added in the enum
  - enums can be declared inside or outside of class but not
    with in any method
  - enums by default final
  - if declared inside class they are static
  - enum objects can not be created explicitly as new keyword
    is not available

    ENUM rules
  - enum constructor has to be private
  - enums can not be private, protected and abstract
  - enums are implicitly public, static, final.
  - The order of appearance of enum constants is
    called their NATURAL ORDERING.

  - Advantages of enums
Typesafe
Namespace
Brittleness
Printed values are Informative

Generics
 - Generics provides abstraction over Types
 - Generics makes type safe code possible
 - Generics provides increased readability

Eg:
public class Box<T>{

T value;

public void put(T value){
this.value = value;
}

public T get(){
return value;
}
}


public static void main(String[] args) {


Box<Integer> b = new Box<Integer>();

b.put(56);//IF we add other than interger value
  // then the compiler is going to give
  // the compilation error.
}

  Note: Collection framework classes uses the generics concept
        extensively.
  Note: Collections are NOT generics.

- Generic Types
- The Diamond Operator(<>)
- Type Parameter Naming Conventions
The most commonly used type parameter names are:
E - Element (used extensively by the
Java Collections Framework)
K - Key
N - Number
T - Type
V - Value
S,U,V etc. - 2nd, 3rd, 4th types

- Generic Methods and Constructors
- Generics and Sub-typing

(ArrayList<Object> ao = new ArrayList<Integer>();//Illegal

- Bounded Type Parameters (x extends Y)
- Wildcards(?)
- Type Erasure

Annotations

      - Annotations provide data about a program that is not part of
the program itself.
      - They have no direct effect on the operation of the code they annotate.

 
      - Annotations can be applied to a program's declarations of classes, fields, methods, and other program elements.
   
      - The annotation appears first, often (by convention) on its own line, and may include elements with named or unnamed values:

@Author(
   name = "Benjamin Franklin",
   date = "3/27/2003"
)
class MyClass() { }

or

@SuppressWarnings(value = "unchecked")
void myMethod() { }

If there is just one element named "value," then the name may be omitted, as in:
@SuppressWarnings("unchecked")
void myMethod() { }

Also, if an annotation has no elements, the parentheses may be omitted, as in:
@Override
void mySuperMethod() { }


  - Annotations have a number of uses, among them:

 Information for the compiler
  - Annotations can be used by the compiler to detect errors or suppress
    warnings.
    Eg: @SuppressWarnings("unchecked"), @Override and @Deprecated


Compiler-time and deployment-time processing
  - Software tools can process annotation information to generate java code, XML files, and so forth.

Runtime processing
  -  Some annotations are available to be examined at runtime

1. Binary Literals
int i = 0B1111;

2. Strings in switch Statements
String str = new String("abc1");
switch (str) {
case "abc":
System.out.println("abc block");
break;
case "xyz":
System.out.println("xyz block");
break;
default:
System.out.println("Deafult block");
break;
}
3.Catching Multiple Exception Types
try{

}catch (NullPointerException | ArithmeticException |
NumberFormatException | ClassCastException |
ClassNotFoundException e) {

}

4. Underscores in Numeric Literals
int i = 1_000_000_000;
5.The try-with autoclosing resources Statement
try(FileInputStream fis = new FileInputStream("abc.txt");
FileInputStream fis2 = new FileInputStream("abc2.txt");) {

} catch (Exception e) {
e.printStackTrace();
}
6. Type Inference for Generic Instance Creation
List<Integer> list = new ArrayList<>();

Thursday, 16 October 2014

Frequently asked SQL Query Interview Questions


SQL Query Interview Questions

Question 1: SQL Query to find second highest salary of Employee
Answer : There are many ways to find second highest salary of Employee in SQL, you can either use SQL Join or Subquery to solve this problem. Here is SQL query using Subquery :

select MAX(Salary) from Employee WHERE Salary NOT IN (select MAX(Salary) from Employee );



Question 2: SQL Query to find Max Salary from each department.
Answer : You can find maximum salary for each department by grouping all records by DeptId and then using MAX() function to calculate maximum salary in each group or each department.

SELECT DeptID, MAX(Salary) FROM Employee GROUP BY DeptID.


This questions become more interesting if Interviewer will ask you to print department name instead of department id, in that case you need to join Employee table with Department using foreign key DeptID, make sure you do LEFT OUTER JOIN to include departments without any employee as well. Here is the query

SELECT DeptName, MAX(Salary) FROM Employee e LEFT JOIN Department d ON e.DeptId = d.DeptID;


Question 3: Write SQL Query to display current date.
Answer : SQL has built in function called GetDate() which returns current timestamp. This will work in Microsoft SQL Server, other vendors like Oracle and MySQL also has equivalent functions.SELECT GetDate();



Question 4: Write an SQL Query to check whether date passed to Query is date of given format or not.
Answer : SQL has IsDate() function which is used to check passed value is date or not of specified format ,it returns 1(true) or 0(false) accordingly. Remember ISDATE() is a MSSQL function and it may not work on Oracle, MySQL or any other database but there would be something similar.

SELECT ISDATE('1/08/13') AS "MM/DD/YY";


It will return 0 because passed date is not in correct format.



Question 5: Write a SQL Query to print the name of distinct employee whose DOB is between 01/01/1960 to 31/12/1975.
Answer : This SQL query is tricky but you can use BETWEEN clause to get all records whose date fall between two dates.SELECT DISTINCT EmpName FROM Employees WHERE DOB BETWEEN ‘01/01/1960’ AND ‘31/12/1975’;




Question 6: Write an SQL Query find number of employees according to gender whose DOB is between 01/01/1960 to 31/12/1975.
Answer :
SELECT COUNT(*), sex from Employees WHERE DOB BETWEEN '01/01/1960' AND '31/12/1975' GROUP BY sex;

Question 7: Write an SQL Query to find employee whose Salary is equal or greater than 10000.
Answer :
SELECT EmpName FROM Employees WHERE Salary>=10000;



Question 8: Write an SQL Query to find name of employee whose name Start with ‘M’
Answer :
SELECT * FROM Employees WHERE EmpName like 'M%';



Question 9: find all Employee records containing the word "Joe", regardless of whether it was stored as JOE, Joe, or joe.
Answer :
SELECT * from Employees WHERE UPPER(EmpName) like '%JOE%';




Question 10: Write a SQL Query to find year from date.
Answer : Here is how you can find Year from a Date in SQL Server 2008
SELECT YEAR(GETDATE()) as "Year";



Question 11 : Write SQL Query to find duplicate rows in a database? and then write SQL query to delete them?
Answer : You can use following query to select distinct records :
SELECT * FROM emp a WHERE rowid = (SELECT MAX(rowid) FROM EMP b WHERE a.empno=b.empno)
to Delete:
DELETE FROM emp a WHERE rowid != (SELECT MAX(rowid) FROM emp b WHERE a.empno=b.empno);

Question 12 : There is a table which contains two column Student and Marks, you need to find all the students, whose marks are greater than average marks i.e. list of above average students.
Answer : This query can be written using sub query as shown below :
SELECT student, marks from table where marks > SELECT AVG(marks) from table)


Question 13 : How do you find all employees which are also manager? .
You have given an standard employee table with an additional column mgr_id, which contains employee id of manager.
Answer : You need to know about self join to solve this problem. In Self Join, you can join two instances of same table to find out additional details as shown below

SELECT e.name, m.name FROM Employee e, Employee m WHERE e.mgr_id = m.emp_id;
this will show employee name and manger name in two column e.g.

name manager_name
John David

One follow-up is to modify this query to include employees which doesn't have manager. To solve that, instead of using inner join, just use left outer join, this will also include employees without managers.

Question 14 : You have a composite index of three columns, and you only provide value of two columns in WHERE clause of a select query? Will Index be used for this operation? For example if Index is on EmpId, EmpFirstName and EmpSecondName and you write query like

SELECT * FROM Employee WHERE EmpId=2 and EmpFirstName='Radhe'

If the given two columns are secondary index column then index will not invoke, but if the given 2 columns contain primary index(first col while creating index) then index will invoke. In this case Index will be used because EmpId and EmpFirstName are primary columns.



Hope this article will help you to take a quick practice whenever you are going to attend any interview and not have much time to go into the deep of each query.

Thursday, 11 September 2014

The Top 5 Most Common SQL Server Performance Problems


I'll make this a count down from 5 to 1, with 1 being the most common technical problem we see.

NUMBER 5: TEMPDB PAGELATCH CONTENTION

I'm starting to see this more and more. It is usually with a system making heavy use of tempdb for some type of ETL process. This is especially common if it is an ongoing "real-time" style ETL process. I'm not saying data loads are the cause of this by the way; I'm just relaying my observations.

The symptoms of this can vary, but some things are always the same. High PAGELATCH waits in tempdb and poor performance recorded for processes using tempdb. I'll typically follow the waits to Top SQL in Performance Advisor, and see lots of queries that use temp tables listed in Top SQL. These queries usually run in milliseconds, and should never be counted among the "Top SQL" for the server. This can have people feeling like these queries are a large part of the problem, but that is not necessarily the case at all. The queries are the victims of the real problem.

Once I'm suspecting this to be the case, I will usually jump to the Disk Activity tab in Performance Advisor to see how tempdb is configured. Most times I actually see the same thing: A busy tempdb with a single data file defined. From here I'll usually recommend reconfiguring tempdb, and direct them to a resource like Jonathan's article for more information.

NUMBER 4: EXPECTING AUTO UPDATE STATISTICS TO KEEP STATISTICS UPDATED

The problem here is that the thresholds for triggering auto statistics updates end up being the same in most cases, even for a very large table. Without going into a very deep explanation, the threshold is ~20% of the rows in the table. So on a really big table it takes a lot of data change to trigger an update. Kevin Kline has a nice, easy to follow explanation of this here as well.

The reason this makes the list is that DBAs seem really surprised to find out that the auto update isn't taking care of things the way the name implies. Then there are also many dbas that believe it should be handled by their maintenance job. Then after looking at the maintenance, they are doing index reorgs most of the time, and that won't update the statistics either (though a rebuild will). I also want to note here that if you are using the fragmentation manager feature in SQL Sentry 7.0 and higher, you can have a running history of when your indexes were reorganized rather than rebuilt. This can help you decide whether the problem you're seeing could be related to auto update not happening.

The lesson here is really to keep an eye on statistics, and make sure they're updated regularly, especially on large tables, which are becoming more and more common as time goes on. Another option here can be to use trace flag 2371 to actually change the formula used to trigger the update. 

NUMBER 3: THE CXPACKET WAIT TYPE

I would say that this is hands down the single most common wait type I see on larger SQL Server systems when someone asks me to look into query performance with them.

There is a lot of information out there on how to deal with this, but sadly I still see a lot of people make the initial assumption that the problem should be solved by having either the query or the entire server set MAXDOP to 1. More often than not the problem can be handled by proper indexing or statistics maintenance. It could also be that the plan cached for this query is just not optimal, and you can mark it for recompile using sp_recompile, set recompile at the query level, or just evict the plan using DBCC FREEPROCCACHE with a plan handle. It is best to exhaust these options before deciding to change MAXDOP to 1 because you could be throwing away a lot of processing power without realizing it.


NUMBER 2: MISUNDERSTOOD "TIMEOUT EXPIRED PRIOR TO THE COMPLETION OF…"

This one is huge. Outside of some very edge case behavior, there are two basic types of timeouts you *might* deal with for SQL Server. These are connection timeouts and operation (or query) timeouts. In both cases these are values set by the client connecting to the SQL Server. On the server side, there is a remote query timeout setting, but this is the very edge case I mentioned and will leave that for another discussion.

I'm going to focus on operation timeouts, since they are the most common. Operation timeout errors from various software tools might be the most misunderstood situation I come across. The cause of these really boils down to one simple thing though: The client executing the command has set a maximum amount of time that it will wait for the command to complete. If this maximum is reached prior to completion the command is aborted. An error is raised from the client.

Many times the timeout error will induce a panic mode, because the error can look a bit intimidating. The reality is, though, that this is not much different than hitting the stop button in SSMS because the query was taking too long. In fact, it will show up exactly the same in a profiler trace with Error = 2 (Aborted).

So, what does a timeout like this really tell us? It tells us that queries are taking longer than expected. We should go into "performance tuning" mode rather than "something is broken" mode. The error information from the client is really just some good information on where you might start to focus your tuning efforts.

If you receive timeout errors from the SQL Sentry monitoring service, and one of the servers you are monitoring is the source, this is not telling you that SQL Sentry is broken. This is SQL Sentry telling you that this server is experiencing performance issues. Again, it is time for "performance tuning" mode. These errors could be easily consumed internally, and retried later, but this would be doing our customers a huge disservice. We believe that you should know about *any* potential problem on your monitored server, even if it is SQL Sentry encountering the problem.

Incidentally, this is true for SQL Sentry, just as it is for any other system that uses an RDBMS for a repository your SQL Sentry database needs some TLC now and again. Without it you may indeed experience some timeouts from your SQL Sentry client. We spend a lot of time tuning our queries for performance before they ever make it out the door, but proper maintenance will ensure they continue to run as intended.

NUMBER 1: MEMORY PRESSURE

This is the big one. As soon as Kevin mentioned wanting this list it's the first thing that popped into my head. Not only because I see it so often, but also because it is so often mistaken for poor disk performance.

There are lots of caches in SQL Server, but the most well-known is the data cache (aka buffer pool). The easiest way to describe the data cache is that it is the data stored in memory, rather than persisted to disk. Being able to store lots of data in memory long term is desirable because working with data in memory is generally much quicker than having to perform physical I/Os.

I could turn this post into a very long discussion on memory pressure in SQL Server at this point, but I promise I will try to avoid that. There is already a ton of information available on this subject, and that is not really the intent of this post. What I will say is that, usually, memory pressure manifests as a few different symptoms. When viewed individually, some of these symptoms can lead you to incorrect, and sometimes costly, conclusions.

The two misleading symptoms are that you may start to see higher than normal latency across the disk subsystem, and you may start to see abnormally high waits related to disk activity. If you look at nothing but these two symptoms, you may come to the conclusion that you need to work on your disk system.

This is why being presented with all relevant metrics on one dashboard is so important. You have to look at the bigger picture, and having the memory-related data available along with the disk activity and waits helps to paint a clearer picture of what is really going on.

Typically what I'll see (along with the disk waits and disk latency) is a PLE (Page Lifetime Expectancy) that is fairly low for this server. I describe it this way because what is good or bad for this value really "depends". The larger your buffer cache is, the higher your "critical" threshold will be for PLE. The more data there is to churn in and out of the buffer, the worse off you will be when the "churn" actually happens. Another consideration is NUMA. The way the PLE counter is calculated can cause this value alone to be very misleading when multiple NUMA nodes are involved, as described by Paul Randal in a blog post about page life expectancy isn't what you think... Luckily in SQL Sentry 7.0 and higher, you can actually see where PLE is for the individual NUMA nodes in history mode, which makes this a bit less of a problem.

I'll usually also see consistently higher lazy writer activity, and SQL Server page faults (SQL Server going to disk). Sometimes I'll see what I call buffer tearing. It's basically when the data buffer is up and down frequently creating a jagged (or torn) edge on the history chart in Performance Advisor. Finally, I may also see an abnormally large plan cache reducing available memory for the data cache.

All of these things together spell memory pressure, and there are various ways to deal with them, but the important thing to note is that this is not a disk issue. It's not saying that your disk system is necessarily wonderful either, but I am saying I wouldn't call up your SAN guy and order a bunch of new hardware based on this situation. Once you get the memory pressure situation under control, SQL Server will not need to go to disk as much, and the few symptoms related to disk may disappear entirely!

The moral here is really to always consider the full picture of performance, because looking at one thing out of context could severely limit your options for a solution.



HONORABLE MENTION: SQL SERVER AGENT HISTORY RETENTION SETTINGS UNLIMITED

We see this enough to include it in this list, and I think anyone that uses SQL Server Agent should be aware of it.

In SQL Server Agent Properties, under History, you can adjust retention settings.



For some reason, I've seen quite a few people set this to unlimited by unchecking both checkboxes. If you do this, and you use Agent jobs frequently, eventually you're going to run into problems with job history in MSDB, because these tables aren't really indexed very well. The settings I'm using above are generally fine for most cases, and if you're using  SQL Sentry event manager, you're keeping this information in the SQL Sentry database anyway, so retaining it here is just redundant.
CONCLUSION

So there are my (current) top 5 most common SQL Server performance issues/topics. For #4 and #5, I actually had to run some numbers to find out what they were, but for the top three, I knew without having to consider it much at all.

Thanks for reading!

Sunday, 10 August 2014

Ice Bucket Challenge


  

The Ice Bucket Challenge, sometimes called the ALS Ice Bucket Challenge, is an activity involving dumping a bucket of ice water on someone's head to promote awareness of the disease Amyotrophic  lateral sclerosis (ALS) and encourage donations to research. It went viral on social media during July–August 2014. In the US, many people participate for the ALS association, and in the UK many people participate for the motor neurone disease association, although some individuals have opted to donate their money from the Ice Bucket Challenge to other organizations.
 The challenge encourages nominated participants to be filmed having a bucket of ice water poured on their heads and then nominating others to do the same. A common stipulation is that nominated participants have 24 hours to comply or forfeit by way of a charitable financial donation.



The Challenge's success

The Ice Bucket Challenge has been a successful campaign. Its combination of competitiveness, social media narcissism, and low barriers to entry have led to more than 2.4 million tagged videos circulating Facebook. Even though 40-50% of the new donors are likely to make one-time gifts only, the Challenge instigated large numbers of people, videos, and donations. The challenge also benefits from a unique balance of mass interest and individual identification.In using social media as its platform, it accessed many people worldwide; in having its participants individually identify potential candidates – calling them out by “tagging” them – it felt personal. Furthermore, the videos are often entertaining. Some celebrities have indulged in longer videos to name-drop, show off their vacations, their homes, their humility, and some even advocate for their own organizations. The average participants keep their videos under a minute,requiring limited commitment from any viewers. Another concept the Challenge benefited from is its ripple effect, inspiring features for articles titled “Top 10 Ice Bucket Challenge Fails”and “10 More of the Best Celebrity Takes on the Ice Bucket Challenge.”Despite its marketing success, critics suggest that the ease of repeating the challenge's spiel do not increase awareness of what the disease actually does and who it is so harmful to.




Rules

Within 24 hours of being challenged, participants must record a video of themselves in continuous footage.First, they are to announce their acceptance of the challenge followed by pouring ice into a bucket of water.Then, the bucket is to be lifted and poured over the participant's head. Then the participant can nominate a minimum of three other people to participate in the challenge.

Whether people choose to donate, perform the challenge, or do both varies.

In one version of the challenge, the participant is expected to donate $10 if they have poured the ice water over their head or donate $100 if they have not. In another version, dumping the ice water over the participant's head is done in lieu of any donation, which has led to some criticisms of the challenge being a form of "slacktivism". Many participants donate $100 in addition to doing the challenge.

Supporting Personal Causes
Some participants who performed the challenge have donated to charities of their choice. This version, while not widely practiced, is generally accepted as a challenge success.