Backpack Tools4 Sql Dev
-
Upload
goncalo-chaves -
Category
Technology
-
view
579 -
download
1
description
Transcript of Backpack Tools4 Sql Dev
![Page 1: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/1.jpg)
XII Encontro da comunidade SQLPort
![Page 2: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/2.jpg)
Name: Gonçalo Chaves Alias: Chaves Job: Senior Analyst Company: Viatecla Im: [email protected] Tw: @gchaves Hobbies: reading, photo, gaming Email: [email protected] Communities: xamlpt, pontonetpt, sqlport
![Page 3: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/3.jpg)
“The biggest problem in databases is the base data…”
![Page 4: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/4.jpg)
Main challenges Why we don’t care Analysis and procedures Tools Use Cases References
![Page 5: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/5.jpg)
Engineers knows programing but they don’t know SQL!
![Page 6: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/6.jpg)
Rookies don’t thing in scalability!
![Page 7: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/7.jpg)
High availability Scale and Scale Trustful transactions Performance and tuning Maintenance and archiving Partitioning Data integrity
![Page 8: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/8.jpg)
The easy path Comfort, learning is a painful process No professional training No time! The big truck rule Scale and trust aren’t known “Microsoft’s lema”
![Page 9: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/9.jpg)
Don’t know the engine Wrong Assumptions Re-use views, queries, with no limits Data type? What? nvarchar don’t fit in all? Unknown Transaction Isolation levels Tons of locks on a single query
![Page 10: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/10.jpg)
Normalization
Careful to much can be inefficient
Appropriate Keys and Indexes Right Primary and FK’s
Choose for relations and integrity
![Page 11: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/11.jpg)
Don’t over on Indexes
Take’s disk space
Drop index for bulk insertion
Some WHERE’s clauses can’t take advantage on ix
Evaluate and test you ix
![Page 12: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/12.jpg)
Each Database is a Database
BETWEEN can be more efficient than operators
Native functions (Convert, format…)
Aggregate functions (max, min, count, …)
![Page 13: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/13.jpg)
The NULL cancer… you must know NULL well
ISNull can be a painful
Wrong assumption on fields
Null datatype vs “Null”
Non safe transaction
Logic looseness
![Page 14: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/14.jpg)
My debug:
Profiler… yeah it’s heavy but it’s useful!
TA – tuning advisor
Activity monitor
Look for index, keys, fragments,
![Page 15: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/15.jpg)
Daily, every sql dev is also an sql admin!
RedGate suite
QueryExpress (light, keep simple)
TableDiff.exe
DMVStats (dataware house)
SQL Server Cache manager
![Page 16: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/16.jpg)
DBA? Where?
SQL Internals Viewer
SQLQueryStress (in dev or stage scenarios)
SQLIO Disk Benchmark tool (on server)
![Page 17: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/17.jpg)
SQL Security
Roles may be insufficient
Prevent SQL injection
Prevent non logic queries that can burn your data
Remember, it’s more easier broke sql security by your app than anything else.
![Page 18: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/18.jpg)
The devil ….
SELECT *
![Page 19: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/19.jpg)
Dam accelerators …. ADO.NET
SQLDATASOURCE
LINQ to SQL
Entity Framework …
![Page 20: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/20.jpg)
Abuses on Group by ; Having; Inner join
Sub queries with sub queries with …
#temp_table for everything…
DML cmd’s
Constraints for everything…
![Page 21: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/21.jpg)
Good sense
Know your data
Maintenance
Job your data Integrity vs Performance
The balance is the key
0
1
2
3
4
5
Jan Fev Mar April May June
Frag
Perf
Disk
![Page 22: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/22.jpg)
Database – xpto 1500 tables
2700 stored procedures
~1.5 M transaction per day Delete in cascade … Broke process
Restart server
![Page 23: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/23.jpg)
Normalize has needed Test your database Schedule jobs Create Index’s where needed Use right tools
full text search, TA, SSIS
![Page 24: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/24.jpg)
Avoid triggers Partitioning Archive data Data type right usage Think in your transaction mode Use safe locks Test, application stress and faulty
![Page 25: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/25.jpg)
Document you DB Keep scripts in safe Update your scripts Use facts not assumptions Cross your test with others Right lock safe usage Define db architecture
![Page 26: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/26.jpg)
A good DB start’s on your apps Cache is more than welcome “The 4 connections challenge..” Multiple Environments keep DB’s updated Keep your analysis update
![Page 27: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/27.jpg)
Developers exists in C# not in SQL – Deal with it!
Train your team – code review; sessions; books
Use the right tools on right scenarios
Integrity vs Performance
Keep in mind security concerns
Make Maintenance plans – from the beginning
![Page 28: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/28.jpg)
Usual blog’s / Communities SQL 2008 internals Write Smart Sql SQL For Smarties Sql forums … sqlport
![Page 29: Backpack Tools4 Sql Dev](https://reader036.fdocuments.in/reader036/viewer/2022081519/559487fc1a28ab1e7d8b4599/html5/thumbnails/29.jpg)
Thank you all Do right SQL before the pain! Follow me at:
http://pontonetpt.org/blogs/chaves http://xamlpt.com/blogs/chaves
[email protected] www.viatecla.com