jQuery - upgrade from version 1.6.x to 1.7

Goal:

Issues to consider when upgrading from jQuery version 1.6 to 1.7. This is a short list and may help identify the real issues you need to concern yourself with in stead of reading through all the release notes

Summary of issues encountered during upgrade:

As you prepare for upgrade to jQuery 1.7 from 1.6.x, this is a quick glimpse of all the issues that are relevant, not sure if it covers all but may be all you need to worry about.

Use this method only for checking checkboxes and radio buttons:
$("input:checked")
This will work regardless of the version of jQuery you are using. Note that $("input).attr("checked") returns true prior to jQuery 1.6. Only retrieve "real" attributes with "attr", in order versions it would also retrieve properties like "tagName", this no longer works with jQuery 1.6.1+

Why does $("input").attr("checked") no longer (from version 1.6.1+) return TRUE or FALSE, because if you look at the HTML (as well as W3C spec) it does not contain a true/false, but the value checked="checked", which is what it should have returned in the first place. $("input").prop("checked") works, return true, because there is in fact a DOM property for "checked" with the value being "true" or "false".

Furthermore, if you want to upgrade to jQuery 1.7 you should only have to worry about this for most part:
1. isNumeric() is new, be careful as the older version jQuery.isNaN() has been deprecated
2. jqXHR success and error have been deprecated
3. When rendering content with text(), white space issue cross-browsers: http://bugs.jquery.com/ticket/3144

Other than the issues above I am not aware of any deprecations you need to worry about.

Hope this helps to get everyone up to version 1.7

SQL Server - Rebuilding Indexes

Goal:

Rebuild indexes in SQL server. This can be done one at a time or with the example script below to rebuild all index for a specified table or for all tables in a given database.


Why?
The data in indexes gets fragmented over time. That means that as the index grows, the newly added rows to the index are physically stored in other sections of the allocated database storage space. Kind of like when you load your Christmas shopping into the trunk of your car and it is full you continue to load some on the back seat, in the same way some storage buffer is created for your index but once that runs out the data is then stored in other storage space and your data in your index is no longer stored in contiguous physical pages. To access the index the database manager has to "string together" disparate fragments to create the full-index and create one contiguous set of pages for that index. Defragmentation fixes that.

What does the fragmentation affect?
Depending of course on how large the table is and how fragmented the data is, can cause SQL Server to perform unnecessary data reads, slowing down SQL Server’s performance.

Which index to rebuild?
As a rule consider that when reorganize a table's clustered index, all other non-clustered indexes on that same table will automatically be rebuilt. A table can only have one clustered index.

How to rebuild all the index for one table:
The DBCC DBREINDEX command will not automatically rebuild all of the indexes on a given table in a database

How to rebuild all indexes for all tables in a given database:

USE [myDB]    -- enter your database name here

DECLARE @tableName varchar(255)

DECLARE TableCursor CURSOR FOR
SELECT table_name FROM information_schema.tables
WHERE table_type = 'base table'

OPEN TableCursor

FETCH NEXT FROM TableCursor INTO @tableName
WHILE @@FETCH_STATUS = 0
BEGIN
DBCC DBREINDEX(@tableName,' ',90)     --a fill factor of 90%
FETCH NEXT FROM TableCursor INTO @tableName
END

CLOSE TableCursor

DEALLOCATE TableCursor


What does this script do?
Reindexes all indexes in all tables of the given database. Each index is filled with a fill factor of 90%. While the command DBCC DBREINDEX runs and rebuilds the indexes, that the table becomes unavailable for use by your users temporarily until the rebuild has completed, so don't do this during production  hours as it will create a shared lock on the tables, although it will allow for read-only uncommitted data reads; i.e.e SELECT.

What is the fill factor?
Is the percentage of space on each index page for storing data when the index is created or rebuilt. It replaces the fill factor when the index was created, becoming the new default for the index and for any other nonclustered indexes rebuilt because a clustered index is rebuilt. When fillfactor is 0, DBCC DBREINDEX uses the fill factor value last specified for the index. This value is stored in the sys.indexes catalog view.

If fillfactor is specified, table_name and index_name must be specified. If fillfactor is not specified, the default fill factor, 100, is used.

How do I determine the level of fragmentation?
Run the DBCC SHOWCONTIG command. However this requires you to specify the ID of both the table and index being. To make it a lot easier by only requiring you to specify the table name and/or index you can run this script:

DECLARE
@ID int,
@IndexID int,
@IndexName varchar(128)

--Specify the table and index names
SELECT @IndexName = ‘index_name’    --name of the index
SET @ID = OBJECT_ID(‘table_name’)  -- name of the table

SELECT @IndexID = IndID
FROM sysindexes
WHERE id = @ID AND name = @IndexName

--Show the level of fragmentation
DBCC SHOWCONTIG (@id, @IndexID)


Here is an example:

DBCC SHOWCONTIG scanning 'Tickets' table...
Table: 'Tickets' (1829581556); index ID: 1, database ID: 13
TABLE level scan performed.
- Pages Scanned................................: 915
- Extents Scanned..............................: 119
- Extent Switches..............................: 281
- Avg. Pages per Extent........................: 7.7
-
Scan Density [Best Count:Actual Count].......: 40.78% [115:282]
- Logical Scan Fragmentation ..................: 16.28%
- Extent Scan Fragmentation ...................: 99.16%
- Avg. Bytes Free per Page.....................: 2457.0
- Avg. Page Density (full).....................: 69.64%
DBCC execution completed. If DBCC printed error messages, contact your system administrator.


What's important here?
The Scan Density; Ideally it should be 100%. As time goes by it drops as fragmentation occurs. When the level drops below 75%, you should consider re-indexing.

Here are the results of the same table and clustered index after running the script:

DBCC SHOWCONTIG scanning 'Tickets' table...
Table: 'Tickets' (1829581556); index ID: 1, database ID: 13
TABLE level scan performed.
- Pages Scanned................................: 692
- Extents Scanned..............................: 87
- Extent Switches..............................: 86
- Avg. Pages per Extent........................: 8.0
-
Scan Density [Best Count:Actual Count].......: 100.00% [87:87]
- Logical Scan Fragmentation ..................: 0.00%
- Extent Scan Fragmentation ...................: 22.99%
- Avg. Bytes Free per Page.....................: 639.8
- Avg. Page Density (full).....................: 92.10%
DBCC execution completed. If DBCC printed error messages, contact your system administrator.


What's different?
The Scan Density has increased from 40.78% to 100%; no fragmentation on the clustered index. Note that since we rebuilt the clustered index, all other index were also rebuilt.
Twitter