sql server best practices in indian style by rajat jaiswal

21
SQL Best Practices SQL SERVER BEST PRACTICES IN INDIAN STYLE

Upload: indiandotnet

Post on 18-Jul-2015

144 views

Category:

Technology


1 download

TRANSCRIPT

SQL Best PracticesSQL SERVER BEST PRACTICES IN INDIAN STYLE

Indiandotnet –

Microsoft user

group

community

Rajat Jaiswal

http://indiandotnet.wordpress.com

HTTPS://facebook.com/indiandotnet

Is this our AGENDA?

BEST PRACTICES IN SQL SERVER

Bada hai To better Hai

Indian mentality but do not apply in database designing (Best Practices in Designing )

Column Name Data Type (current Data type) Length Data Type(after change) Length

EnrollmentHistoryId numeric 9 numeric 9

EnrollmentId numeric 9 numeric 9

ClassId numeric 9 tinyint 1

WorkSheetId numeric 9 int 4

classTeacherId numeric 9 int 4

ClassRoomId numeric 9 tinyint 1

centerId numeric 9 tinyint 1

HomeAddressId nchar 20 int 4

FriendsId numeric 9 int 4

Comments varchar 300 varchar 300

Notes varchar 300 varchar 0

CreatedBy numeric 9 int 4

CreatedDate datetime 8 small datetime 4

ModifiedBy numeric 9 int 4

ParentId numeric 9 numeric 9

ModifiedDate datetime 8 datetime 8

StatusId numeric 9 tinyint 1

SynchStatusId numeric 9 tinyint 1

Rows 753 368

No of rows in curernt database 5000000

bytes 3765000000 1840000000

KB 3676757.81 1796875

MB 3590.5838 1754.76074

GB 3.506429 1.71363354

space diffrence (GB) (aprox) 1.79279596

* above result is by just sum of max length ofvariable & non variable columns

REASON To Think

Are Ye bhi Yaad

rakho NULL hi to

Hai

It is not only about NULL but all the constraints

- thik hai / chalta hai - Indian attitude

REASON TO THINK

I LOVE “ Not IN”

MUZE TO SIRF NOT IN CLAUSE EASY LAGTA HAI - TRY JOIN AND OTHER FEATURES ALSO .

ALTHOUGH IT NOT ALWAYS BAD

”Let see demo

REASON To Think

SAB AANE DO

kaha paise lag

rahe hai

Free me sab chalega

BAAD ME DEKH LENGE ATTITUDE

NO FILTER CLAUSE

”Let see demo

REASON To Think

HAR SLOW QUERY

KA ILLAGE HAI

MERE PASS INDEX

HAI MERE PASS

PERFORMANCE WILL BE IMPROVE BY INDEX ?

Let see demo

REASON To Think

FUNCTION HI

FUNCTION

Function is good to have but if we not use it properly it will slow down system

”Let see demo

REASON To Think