miércoles, 19 de enero de 2011

MySQL slow queries

sudo mysqld_safe --timezone=+0:00 --long_query_time=1 --log-slow-queries=/tmp/slow.log --log-queries-not-using-indexes

Sort by Rows_examined:

grep Query_time /tmp/slow.log |sort -n -k9
# Query_time: 0.007019 Lock_time: 0.000098 Rows_sent: 0 Rows_examined: 65
# Query_time: 0.001595 Lock_time: 0.000042 Rows_sent: 0 Rows_examined: 66
# Query_time: 0.002316 Lock_time: 0.000101 Rows_sent: 0 Rows_examined: 72
# Query_time: 0.003357 Lock_time: 0.000380 Rows_sent: 0 Rows_examined: 83
# Query_time: 0.003342 Lock_time: 0.000403 Rows_sent: 0 Rows_examined: 116
# Query_time: 0.004729 Lock_time: 0.000319 Rows_sent: 0 Rows_examined: 116
# Query_time: 0.002406 Lock_time: 0.000043 Rows_sent: 0 Rows_examined: 205

jueves, 13 de enero de 2011

Unit Tests' value in TDD

Hierarchy of tests:
  • Acceptance: Does the whole system work?
  • Integration: Does our code work against code we can't change?
  • Unit: Do our objects do the right thing, are they convenient to work with?

Unit Tests' value in TDD:
  • Write loosely coupled components
  • Detect errors while the context is fresh in our mind
  • Add an executable description of what the code does (documentation)
  • Focus: discouraging unnecessary features
  • Rythm: tests tell what to do next
  • Trust: tests give a reason to trust you
ref:
- Extreme Programming Explained
- Growing Object-Oriented Software, Guided by Tests