-
-
Recent Posts
Recent Comments
Categories
- Bash
- BerkeleyDB
- Browsers
- Cable
- Chrome
- Cool Problems
- CPAN
- CSS
- Data Structures
- Databases
- DNS
- Editors
- Errors
- Everything Else
- Fedora
- Firefox
- Firewall
- Flash
- Forking
- Hardware
- HTML
- ImageMagick
- Images
- Internet Explorer
- IpTables
- Lingo
- Linux
- Log4perl
- Mediawiki
- Monitoring
- Munin
- MySQL
- Netgear
- Perl
- PHP
- PhpMyAdmin
- Postfix
- Regular Expressions
- Routers
- RPM
- Samba
- Screen
- SSH
- SSHFS
- Subversion
- Synergy
- Troubleshooting
- Ubuntu
- VIM
- Windows
- Windows Vista
- Wordpress
- YUM
Blogroll
Archives
Tags
September 2010 M T W T F S S « Aug 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Meta
CNN.com- Bonnie Blue actress from 'GWTW' dies
- President to aides: Find economic spark
- Hurricane Earl downgraded as it approaches East Coast
- Workers rescued after oil platform fire
- BP uncaps oil well in Gulf
- Mideast peace talks start
- Convicted killer spared death penalty
- Opinion: Social Security can help states
- U.S., Iran battle on basketball court
- She drops 100 pounds, gains new life
BBC- Europe agrees finance watchdogs
- ICC chief executive on cricket charges
- Explosion on Gulf of Mexico rig
- Tanker runs aground off N Canada
- DCAL cuts 'will mean job losses'
- Pakistan trio hit by ICC charges
- Strike 'kills Afghan civilians'
- Bid for Middle East peace begins
- The mint with a whole lot of food miles
- Man 'strangled wife and hid body'
AL JAZEERA ENGLISH (AJE)
Category Archives: MySQL
MySQL Best Data Types For Common Types Of Data
Primary Key : INT UNSIGNED – About 4.3 billion available IDs. Going unsigned gives you the extra 2 billion. Phone Number : VARCHAR – Phone numbers are identifiers that happen to use digits. – See this post. Price : FLOAT … Continue reading
Posted in MySQL
Leave a comment
How To Determine a Good Unique Key
Make the unique key long enough to allow for reasonable duplication of names in the real world For example, for a table of people, a unique key of country/state/city/address might be a good choice. This allows for two people in … Continue reading
Posted in MySQL
Leave a comment
How To Store Phone Numbers in MySQL
Store phone numbers as strings, not numbers. Phone numbers are identifiers that happen to use digits. Phone numbers starting with zero are valid, but may be interpreted as octal by a programming language. Strip the phone number to only digits … Continue reading
How To Use MySQL EXPLAIN
This stuff has helped improve many of my queries. The basics: Its bad whenever you have the second table in the explain returning more than 1 row. The driving table is first and all other tables joined to it should … Continue reading
Posted in MySQL
Leave a comment
Directed Acyclic Graph Information
SQL with Trees and Graphs http://www.artfulsoftware.com/mysqlbook/sampler/mysqled1ch20.html MySQL Stored Procedure of Dijkstra’s Algorithm http://www.artfulsoftware.com/infotree/queries.php?&bw=1059#766 http://www.codeproject.com/KB/database/Modeling_DAGs_on_SQL_DBs.aspx More on Nested Tree Model http://dev.mysql.com/tech-resources/articles/hierarchical-data.html http://articles.sitepoint.com/article/hierarchical-data-database/2
Posted in Data Structures, MySQL
Leave a comment
SQL: ORDER BY With Zeroes Last
How to sort values from lowest to highest, but leaving the zeroes last: SELECT foo FROM bar order by foo = 0, foo ASC
Posted in MySQL
Leave a comment
How To Fix "The total number of locks exceeds the lock table size"
This usually happens when you’re doing massive queries on InnoDB tables: ERROR 1206 (HY000): The total number of locks exceeds the lock table size In /etc/my.cnf, do something like this: innodb_buffer_pool_size=524288000 By default, MySQL sets innodb_buffer_pool_size to 8MB. 500 megabytes … Continue reading
Posted in Linux, MySQL
Leave a comment
How To Add a MySQL Column with Index
ALTER TABLE mytable ADD mycolumn INT UNSIGNED NOT NULL AFTER othercolumn , ADD INDEX ( mycolumn );
MySQL Slow Query Optimization Tips
Slow Query Example SELECT widget_id , widget_name , COUNT(DISTINCT type) AS num_types FROM widget GROUP BY type ORDER BY num_types DESC With lots (>100K) of rows, this query will get slow because it orders on an aggregate COUNT DISTINCT function. … Continue reading
Posted in MySQL
Leave a comment
How to Optimize MySQL Queries Using Indexes
When optimizing a query, the order of fields matter in a multi-field index. In general, you should use the most selective fields first. For example, in a hypothetical location index, use zip, city, state, rather than the reverse. Source: MySQL … Continue reading
Posted in MySQL
Leave a comment
MySQL Schema Best Practices
Use UNSIGNED INT (or BIGINT if needed) for primary key, since you don’t need negative primary keys. Don’t use ON DELETE CASCADE, since you might delete rows you wanted to keep. Explicitly delete rows in your code. Don’t use ON … Continue reading
How to Quickly Add Multiple Indexes to a MySQL Table
Instead of: ALTER TABLE my_table ADD KEY `key1` (`apple`); ALTER TABLE my_table ADD KEY `key2` (`banana`); do this: ALTER TABLE my_table ADD KEY `key1` (`apple`), ADD KEY `key2` (`banana`);
Posted in MySQL
Leave a comment
Munin MySQL plugin not working or blank graphs
Add a user “nobody” only accessible via “localhost” with no password and only “usage” privileges. If you look at the MySQL log, you will see the munin client accessing MySQL via the “nobody” user. To test the munin client, connect … Continue reading
Posted in Linux, Munin, MySQL
Leave a comment
How to move a column in MySQL
Move a column after some other column mysql> ALTER TABLE mytable MODIFY COLUMN mycolumn INT AFTER someothercolumn; Move a column to the first position mysql> ALTER TABLE mytable MODIFY COLUMN mycolumn INT FIRST;
Troubleshooting a MySQL query
Use EXPLAIN to show which indexes are being used. mysql> EXPLAIN SELECT mycolumns FROM table1 LEFT JOIN table2;\G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: ag type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: 1010 … Continue reading
Posted in MySQL
Leave a comment