<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: mysql hope</title>
	<link>http://ask.metafilter.com/44389/mysql-hope/</link>
	<description>Comments on Ask MetaFilter post mysql hope</description>
	<pubDate>Mon, 14 Aug 2006 12:50:24 -0800</pubDate>
	<lastBuildDate>Mon, 14 Aug 2006 12:50:24 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: mysql hope</title>
		<link>http://ask.metafilter.com/44389/mysql-hope</link>	
		<description>MySQL refuses to index my table properly, because the data I&apos;m looking for is only three letters long. &lt;br /&gt;&lt;br /&gt; I wrote a little database postcode app, and wondered for ages why it wasn&apos;t working properly. Then I realised it would return results perfectly well when I searched for a four-character postcode, like BA16 -- it was just ignoring the three-character ones, like BA5. Is there any way to turn off (or work around) this idiotic MySQL behaviour?&lt;br&gt;
&lt;br&gt;
If it matters, I&apos;m using fulltext indexes with this SQL:&lt;br&gt;
SELECT * FROM &apos;pc&apos; WHERE MATCH (town,county,postcodes,area,county) AGAINST (&apos;BA5&apos;).</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2006:site.44389</guid>
		<pubDate>Mon, 14 Aug 2006 12:40:06 -0800</pubDate>
		<dc:creator>reklaw</dc:creator>
		
			<category>mysql</category>
		
			<category>postcodes</category>
		
	</item> <item>
		<title>By: orthogonality</title>
		<link>http://ask.metafilter.com/44389/mysql-hope#680534</link>	
		<description>I will tell you how to fix this for my standard consulting fee, or you can look it up in the MySQL docs.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
MySQL 5.1 Reference Manual :: 12.7 Full-Text Search Functions:&lt;blockquote&gt;&lt;a href=&quot;http://mysql.com/doc/refman/5.1/en/fulltext-search.html&quot; title=&quot;MySQL 5.1 Reference Manual :: 12.7 Full-Text Search Functions&quot;&gt;Some words are ignored in full-text searches:&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
    *      Any word that is too short is ignored. The default minimum length of words that are found by full-text searches is four characters.&lt;br&gt;
    *      Words in the stopword list are ignored. A stopword is a word such as &quot;the&quot; or &quot;some&quot; that is so common that it is considered to have zero semantic value. There is a built-in stopword list, but it can be overwritten by a user-defined list.&lt;br&gt;
&lt;br&gt;
The default stopword list is given in Section 12.7.3, &quot;Full-Text Stopwords&quot;. The default minimum word length and stopword list can be changed as described in Section 12.7.5, &quot;Fine-Tuning MySQL Full-Text Search&quot;.&lt;/blockquote&gt;&lt;br&gt;
&lt;br&gt;
MySQL 5.1 Reference Manual :: 12.7.5 Fine-Tuning MySQL Full-Text Search:&lt;br&gt;
&lt;blockquote&gt;&lt;a href=&quot;http://mysql.com/doc/refman/5.1/en/fulltext-fine-tuning.html&quot; title=&quot;MySQL 5.1 Reference Manual :: 12.7.5 Fine-Tuning MySQL Full-Text Search&quot;&gt;The minimum and maximum lengths&lt;/a&gt; of words to be indexed are defined by the ft_min_word_len and ft_max_word_len system variables. (See Section 5.2.2, &quot;Server System Variables&quot;.) The default minimum value is four characters; the default maximum is version dependent. If you change either value, you must rebuild your FULLTEXT indexes. For example, if you want three-character words to be searchable, you can set the ft_min_word_len variable by putting the following lines in an option file:&lt;br&gt;
&lt;br&gt;
[mysqld]&lt;br&gt;
ft_min_word_len=3&lt;/blockquote&gt;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
(The MySQL documention is your friend.)</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.44389-680534</guid>
		<pubDate>Mon, 14 Aug 2006 12:50:24 -0800</pubDate>
		<dc:creator>orthogonality</dc:creator>
	</item><item>
		<title>By: disillusioned</title>
		<link>http://ask.metafilter.com/44389/mysql-hope#680536</link>	
		<description>What are the results when you EXPLAIN that query, such that you&apos;re certain it&apos;s not using your index?&lt;br&gt;
&lt;br&gt;
MySQL has a built-in optimizer that will examine the structure of a query and attempt to estimate the time saved by using an index. If it determines that it&apos;s better off ignoring the index and just going at it, it&apos;ll do just that.&lt;br&gt;
&lt;br&gt;
How many different postcodes do you have, or what other information is contained in the field that you&apos;re using a FULLTEXT index for (which is somewhat unreliable with single strings)?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.44389-680536</guid>
		<pubDate>Mon, 14 Aug 2006 12:51:44 -0800</pubDate>
		<dc:creator>disillusioned</dc:creator>
	</item><item>
		<title>By: reklaw</title>
		<link>http://ask.metafilter.com/44389/mysql-hope#680541</link>	
		<description>orthogonality: How would you go about changing that on a shared web hosting server? Would you ever be able to?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.44389-680541</guid>
		<pubDate>Mon, 14 Aug 2006 12:56:46 -0800</pubDate>
		<dc:creator>reklaw</dc:creator>
	</item><item>
		<title>By: wackybrit</title>
		<link>http://ask.metafilter.com/44389/mysql-hope#680550</link>	
		<description>This doesn&apos;t seem like the sort of incidence that you&apos;d want to use FULLTEXT. Just index the first 4 chars of postcode and use LIKE (or a LEFT() and =). It&apos;ll still use the indexes (although you can check this). The amount of postcodes in the United Kingdom is trivial. Do you need to search county, town, etc, for postcodes?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.44389-680550</guid>
		<pubDate>Mon, 14 Aug 2006 13:02:03 -0800</pubDate>
		<dc:creator>wackybrit</dc:creator>
	</item><item>
		<title>By: orthogonality</title>
		<link>http://ask.metafilter.com/44389/mysql-hope#680560</link>	
		<description>&lt;b&gt;reklaw&lt;/b&gt; &lt;a href=&apos;http://ask.metafilter.com/mefi/44389#680541&apos;&gt;writes&lt;/a&gt;  &lt;em&gt;&quot;orthogonality: How would you go about changing that on a shared web hosting server? Would you ever be able to?&quot;&lt;/em&gt;&lt;br&gt;
&lt;br&gt;
 If you&apos;ve got your own instance of the mysql server running on the shared host, you&apos;re good to go. If not, you&apos;re out of luck, because other users of the database won&apos;t want to make the min length 3.&lt;br&gt;
&lt;br&gt;
But the real answer is the one wackybrit gave you; there&apos;s unlikely to be a good reason to be using fulltext to look for postal codes.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.44389-680560</guid>
		<pubDate>Mon, 14 Aug 2006 13:06:31 -0800</pubDate>
		<dc:creator>orthogonality</dc:creator>
	</item><item>
		<title>By: reklaw</title>
		<link>http://ask.metafilter.com/44389/mysql-hope#680578</link>	
		<description>The reason I&apos;m using fulltext is that I&apos;ve got someone else&apos;s silly dirty database with comma-separated postcodes in each column, like this:&lt;br&gt;
&lt;br&gt;
column one: name of place&lt;br&gt;
column two: postcode, postcode, postcode, postcode&lt;br&gt;
&lt;br&gt;
Daft, I know.&lt;br&gt;
&lt;br&gt;
I think I do have my own instance of the mysql server running, though, although I&apos;ve no idea how to edit the config. Do I have to mess around with a unix shell or something?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.44389-680578</guid>
		<pubDate>Mon, 14 Aug 2006 13:13:14 -0800</pubDate>
		<dc:creator>reklaw</dc:creator>
	</item><item>
		<title>By: orthogonality</title>
		<link>http://ask.metafilter.com/44389/mysql-hope#680605</link>	
		<description>&lt;b&gt;reklaw&lt;/b&gt; &lt;a href=&apos;http://ask.metafilter.com/mefi/44389#680578&apos;&gt;writes&lt;/a&gt;  &lt;em&gt;&quot;I think I do have my own instance of the mysql server running, though, although I&apos;ve no idea how to edit the config. Do I have to mess around with a unix shell or something?&quot;&lt;/em&gt;&lt;br&gt;
&lt;br&gt;
This way will take you to hell. You&apos;d have to change the value, and then re-index. And make sure that anyone who indexes in the future with myisamchk passes the same min length parameter -- if they donm&apos;t, the query breaks. MySQL Full-Text Search is half-baked, and its re-indexing is pretty bad too. (It&apos;s often faster to drop indices than to repair them, as a project &lt;s&gt;I&apos;m working on&lt;/s&gt; just completed for disillusioned demonstrates.)&lt;br&gt;
&lt;br&gt;
Why not just fix the database? In the long run, this will be easier and more maintainable.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.44389-680605</guid>
		<pubDate>Mon, 14 Aug 2006 13:25:09 -0800</pubDate>
		<dc:creator>orthogonality</dc:creator>
	</item><item>
		<title>By: reklaw</title>
		<link>http://ask.metafilter.com/44389/mysql-hope#680789</link>	
		<description>Note for future Google searchers etc.: I couldn&apos;t be bothered to fix this properly, so I just did a find-and-replace to make all my commas into &quot;ZZZ&quot; -- MySQL indexes &quot;BA5ZZZ&quot;, and it&apos;s trivial to strip all occurances of ZZZ from the output. OMG HAX. Don&apos;t worry, this script is just for my own use anyway...</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.44389-680789</guid>
		<pubDate>Mon, 14 Aug 2006 15:09:16 -0800</pubDate>
		<dc:creator>reklaw</dc:creator>
	</item><item>
		<title>By: orthogonality</title>
		<link>http://ask.metafilter.com/44389/mysql-hope#680870</link>	
		<description>Oh dear god in heaven.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.44389-680870</guid>
		<pubDate>Mon, 14 Aug 2006 16:24:04 -0800</pubDate>
		<dc:creator>orthogonality</dc:creator>
	</item><item>
		<title>By: delfuego</title>
		<link>http://ask.metafilter.com/44389/mysql-hope#680924</link>	
		<description>Yeah, I&apos;m right there with you ortho.  Oh dear god.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.44389-680924</guid>
		<pubDate>Mon, 14 Aug 2006 16:58:08 -0800</pubDate>
		<dc:creator>delfuego</dc:creator>
	</item><item>
		<title>By: flabdablet</title>
		<link>http://ask.metafilter.com/44389/mysql-hope#681053</link>	
		<description>Now watch that kluge turn up in Microsoft Postcodes :-)</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.44389-681053</guid>
		<pubDate>Mon, 14 Aug 2006 18:54:12 -0800</pubDate>
		<dc:creator>flabdablet</dc:creator>
	</item><item>
		<title>By: ijoshua</title>
		<link>http://ask.metafilter.com/44389/mysql-hope#681063</link>	
		<description>ortho + wackybrit, good advice going unheeded.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.44389-681063</guid>
		<pubDate>Mon, 14 Aug 2006 19:05:18 -0800</pubDate>
		<dc:creator>ijoshua</dc:creator>
	</item><item>
		<title>By: Pinback</title>
		<link>http://ask.metafilter.com/44389/mysql-hope#681073</link>	
		<description>Orthogonality: in the interests of learning, what would be the right way to do this?&lt;br&gt;
&lt;br&gt;
1) If the data is just simply (locality, csv_postcodes), create the table in the form of (unique_postcode, locality).&lt;br&gt;
&lt;br&gt;
2) If it&apos;s any more complex e.g. actual address data, use linked tables to a (unique_postcode, locality) table and set indexes based on the most common query type.&lt;br&gt;
&lt;br&gt;
3) Something else?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.44389-681073</guid>
		<pubDate>Mon, 14 Aug 2006 19:15:18 -0800</pubDate>
		<dc:creator>Pinback</dc:creator>
	</item><item>
		<title>By: orthogonality</title>
		<link>http://ask.metafilter.com/44389/mysql-hope#681642</link>	
		<description>&lt;b&gt;Pinback&lt;/b&gt; &lt;a href=&apos;http://ask.metafilter.com/mefi/44389#681073&apos;&gt;writes&lt;/a&gt;  &lt;em&gt;&quot;in the interests of learning, what would be the right way to do this?&quot;&lt;/em&gt;&lt;br&gt;
&lt;br&gt;
Yeah, you pretty much have it. The &quot;rule&quot; is, every entity has a single row in some table.&lt;br&gt;
&lt;br&gt;
An entity is any thing you want to represent in the database, possibly including relationships among other things, or even consisting of metadata. That&apos;s the essence of database normalization. If you don&apos;t normalize, you have duplicated entities, which means you can simultaneously represent one real thing in two different, contradictory states.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.44389-681642</guid>
		<pubDate>Tue, 15 Aug 2006 10:47:36 -0800</pubDate>
		<dc:creator>orthogonality</dc:creator>
	</item><item>
		<title>By: reklaw</title>
		<link>http://ask.metafilter.com/44389/mysql-hope#681759</link>	
		<description>Yeah, totally. The moral of the story is, whoever made the database originally doesn&apos;t know shit about databases. Comma-separated (or pipe-separated, or whatever) fields break the ENTIRE POINT of them.&lt;br&gt;
&lt;br&gt;
I guess the truly-right thing to do would be to write a script that would take each postcode and make it its own row -- but that would, of course, require both writing the script to begin with, and then running it over the entire db. Still, I feel a little guilty about my kludge, even though I&apos;m the only one to have to suffer with it.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.44389-681759</guid>
		<pubDate>Tue, 15 Aug 2006 12:15:52 -0800</pubDate>
		<dc:creator>reklaw</dc:creator>
	</item><item>
		<title>By: Pinback</title>
		<link>http://ask.metafilter.com/44389/mysql-hope#682286</link>	
		<description>Thanks, ortho - I knew reklaw&apos;s &quot;solution&quot; was horribly, horribly wrong, and was just curious to know if my thinking was on the right track (and to elicit a more generically useful explanation for future AskMeologists).&lt;br&gt;
&lt;br&gt;
Thankfully, reklaw &lt;em&gt;knows&lt;/em&gt; his solution is pretty nasty. But, as a non-programmer who&apos;s just good enough to create ugly 1000-line hacks in PHP or JavaScript, it&apos;s the sort of sideways solution to a problem that would cross my mind for ... oh, maybe 5 seconds? ... before I disgusted even myself ;-)&lt;br&gt;
&lt;br&gt;
Though, I admit, I might use something like it if necessary as part of a quick-and-dirty to initially populate a new table...</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.44389-682286</guid>
		<pubDate>Tue, 15 Aug 2006 23:53:55 -0800</pubDate>
		<dc:creator>Pinback</dc:creator>
	</item>
	</channel>
</rss>
