Backpack Tools4 Sql Dev

754 views

Published on

A brief of some SQL base advices in order to keep your DB more accurate, optimized and safe.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
754
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Backpack Tools4 Sql Dev

  1. 1. XII Encontro da comunidade SQLPort
  2. 2.  Name: Gonçalo Chaves Alias: Chaves Job: Senior Analyst Company: Viatecla Im: evolution69@msn.com Tw: @gchaves Hobbies: reading, photo, gaming Email: gchaves@viatecla.com Communities: xamlpt, pontonetpt, sqlport
  3. 3. “The biggest problem in databases is the base data…”
  4. 4.  Main challenges Why we don’t care Analysis and procedures Tools Use Cases References
  5. 5.  Engineers knows programing but they don’t know SQL!
  6. 6.  Rookies don’t thing in scalability!
  7. 7.  High availability Scale and Scale Trustful transactions Performance and tuning Maintenance and archiving Partitioning Data integrity
  8. 8.  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”
  9. 9.  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
  10. 10.  Normalization  Careful to much can be inefficient Appropriate Keys and Indexes Right Primary and FK’s  Choose for relations and integrity
  11. 11.  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
  12. 12.  Each Database is a Database  BETWEEN can be more efficient than operators  Native functions (Convert, format…)  Aggregate functions (max, min, count, …)
  13. 13.  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
  14. 14.  My debug:  Profiler… yeah it’s heavy but it’s useful!  TA – tuning advisor  Activity monitor  Look for index, keys, fragments,
  15. 15.  Daily, every sql dev is also an sql admin!  RedGate suite  QueryExpress (light, keep simple)  TableDiff.exe  DMVStats (dataware house)  SQL Server Cache manager
  16. 16.  DBA? Where?  SQL Internals Viewer  SQLQueryStress (in dev or stage scenarios)  SQLIO Disk Benchmark tool (on server)
  17. 17.  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.
  18. 18.  The devil …. SELECT *
  19. 19.  Dam accelerators ….  ADO.NET  SQLDATASOURCE  LINQ to SQL  Entity Framework …
  20. 20.  Abuses on  Group by ; Having; Inner join  Sub queries with sub queries with …  #temp_table for everything…  DML cmd’s  Constraints for everything…
  21. 21.  Good sense  Know your data 5 Maintenance 4  Job your data 3 Frag Integrity vs Performance 2 Perf Disk 1  The balance is the key 0 Jan Fev Mar April May June
  22. 22.  Database – xpto  1500 tables  2700 stored procedures  ~1.5 M transaction per day Delete in cascade …  Broke process  Restart server
  23. 23.  Normalize has needed Test your database Schedule jobs Create Index’s where needed Use right tools  full text search, TA, SSIS
  24. 24.  Avoid triggers Partitioning Archive data Data type right usage Think in your transaction mode Use safe locks Test, application stress and faulty
  25. 25.  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
  26. 26.  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
  27. 27.  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
  28. 28.  Usual blog’s / Communities SQL 2008 internals Write Smart Sql SQL For Smarties Sql forums … sqlport 
  29. 29.  Thank you all  Do right SQL before the pain! Follow me at: http://pontonetpt.org/blogs/chaves http://xamlpt.com/blogs/chaves gchaves@viatecla.com www.viatecla.com

×