7. High availability
Scale and Scale
Trustful transactions
Performance and tuning
Maintenance and archiving
Partitioning
Data integrity
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. 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. Normalization
Careful to much can be inefficient
Appropriate Keys and Indexes
Right Primary and FK’s
Choose for relations and integrity
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. Each Database is a Database
BETWEEN can be more efficient than operators
Native functions (Convert, format…)
Aggregate functions (max, min, count, …)
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. My debug:
Profiler… yeah it’s heavy but it’s useful!
TA – tuning advisor
Activity monitor
Look for index, keys, fragments,
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. DBA? Where?
SQL Internals Viewer
SQLQueryStress (in dev or stage scenarios)
SQLIO Disk Benchmark tool (on server)
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.
19. Dam accelerators ….
ADO.NET
SQLDATASOURCE
LINQ to SQL
Entity Framework …
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. 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. Database – xpto
1500 tables
2700 stored procedures
~1.5 M transaction per day
Delete in cascade …
Broke process
Restart server
23. Normalize has needed
Test your database
Schedule jobs
Create Index’s where needed
Use right tools
full text search, TA, SSIS
24. Avoid triggers
Partitioning
Archive data
Data type right usage
Think in your transaction mode
Use safe locks
Test, application stress and faulty
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. 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. 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
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