<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Prodromus &#187; Query Optimization</title>
	<atom:link href="http://www.prodromus.com/category/mysql/query-optimization/feed" rel="self" type="application/rss+xml" />
	<link>http://www.prodromus.com</link>
	<description>A forerunner to the future...</description>
	<lastBuildDate>Thu, 19 Jan 2012 22:32:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>MySQL &#8211; Select rows from a table when a field starts with a number</title>
		<link>http://www.prodromus.com/2010/12/22/mysql-select-rows-from-a-table-when-a-field-starts-with-a-number</link>
		<comments>http://www.prodromus.com/2010/12/22/mysql-select-rows-from-a-table-when-a-field-starts-with-a-number#comments</comments>
		<pubDate>Wed, 22 Dec 2010 19:33:46 +0000</pubDate>
		<dc:creator>Prodromus</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Query Optimization]]></category>
		<category><![CDATA[character class]]></category>
		<category><![CDATA[Pattern matching]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[Regular expression]]></category>
		<category><![CDATA[Select]]></category>
		<category><![CDATA[table]]></category>

		<guid isPermaLink="false">http://www.prodromus.com/?p=353</guid>
		<description><![CDATA[A common request is how to select records from a table when a specific field starts with a number. This request often is used when searching free-form text fields where the fields were used to provide an answer field to a question. The simplest way to attack this is by using a regular expression. For [...]]]></description>
			<content:encoded><![CDATA[<p>A common request is how to select records from a table when a specific field starts with a number.  This request often is used when searching free-form text fields where the fields were used to provide an answer field to a question.</p>
<p>The simplest way to attack this is by using a regular expression.  For example:</p>
<p>SELECT * FROM BadlyDesignedTable WHERE AnswerColumn regexp &#8216;^[0-9]+&#8217;;</p>
<p>or<br />
SELECT * FROM BadlyDesignedTable WHERE AnswerColumn RLIKE &#8216;^[0-9]+&#8217;;</p>
<p><a class="zem_slink" title="Regular expression" rel="wikipedia" href="http://en.wikipedia.org/wiki/Regular_expression">Regex</a> and RLIKE are compatible keywords that both represent regular expression matching.</p>
<p>The regex is described as follows :</p>
<p>^    - Start anchor, used to ensure the <a class="zem_slink" title="Pattern matching" rel="wikipedia" href="http://en.wikipedia.org/wiki/Pattern_matching">pattern matches</a> start of the string.<br />
[    - Start of <a class="zem_slink" title="Character class" rel="wikipedia" href="http://en.wikipedia.org/wiki/Character_class">character class</a>.<br />
0-9  - Any digit<br />
]    - End of character class</p>
<h6 class="zemanta-related-title" style="font-size: 1em;">Related articles</h6>
<ul class="zemanta-article-ul">
<li class="zemanta-article-ul-li"><a href="http://ask.metafilter.com/173434/How-can-I-select-this-in-SQL">How can I select this in SQL?</a> (ask.metafilter.com)</li>
<li class="zemanta-article-ul-li"><a href="http://www.mt-soft.com.ar/2010/07/19/test-regular-expressions-in-your-browser/">Test Regular Expressions in Your Browser</a> (mt-soft.com.ar)</li>
</ul>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><img class="zemanta-pixie-img" style="border: none; float: right;" src="http://img.zemanta.com/pixy.gif?x-id=12bfbaa8-f424-4e31-82c2-084467a3e4ea" alt="" /></div>
]]></content:encoded>
			<wfw:commentRss>http://www.prodromus.com/2010/12/22/mysql-select-rows-from-a-table-when-a-field-starts-with-a-number/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MySQL &#8211; Should you put an index on a Boolean field to help query performance?</title>
		<link>http://www.prodromus.com/2010/06/14/mysql-should-you-put-an-index-on-a-boolean-field-to-help-query-performance</link>
		<comments>http://www.prodromus.com/2010/06/14/mysql-should-you-put-an-index-on-a-boolean-field-to-help-query-performance#comments</comments>
		<pubDate>Mon, 14 Jun 2010 13:58:23 +0000</pubDate>
		<dc:creator>Prodromus</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Query Optimization]]></category>
		<category><![CDATA[Boolean]]></category>
		<category><![CDATA[cardinality]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[Indexing]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[table]]></category>
		<category><![CDATA[trade-off]]></category>
		<category><![CDATA[type]]></category>

		<guid isPermaLink="false">http://www.prodromus.com/?p=288</guid>
		<description><![CDATA[I am often asked if it makes sense to place an index on a Boolean field in order to improve query performance.  In general, because a boolean value can only have three values (True, False, Null), this low cardinality would suggest that adding an index will not help performance, as the query optimizer will still [...]]]></description>
			<content:encoded><![CDATA[<p>I am often asked if it makes sense to place an index on a Boolean field in order to improve query performance.  In general, because a boolean value can only have three values (True, False, Null), this low cardinality would suggest that adding an index will not help performance, as the query optimizer will still usually perform a table-scan if you have an even distribution of values within your DB.</p>
<p>One situation in which an index on a boolean field (or other low cardinality field) might be useful is if there are relatively few of one of the values, for example 5 True values in a table of millions of records and you are searching for those few values on a regular basis.</p>
<p>However, y<span style="font-size: 13.3333px;">ou might index a boolean value on a <em>combination</em> of fields. </span><span style="font-size: 13.3333px;">Indexing on a single Boolean might be pointless, because there&#8217;s only 2 (or 3) values.  However, indexing on 16 boolean values has the potential of  2^16 values.  I</span><span style="font-size: 13.3333px;">t might help to make a combined index but you should understand how the combined index can and cannot be used and be aware that the order of the columns matters. </span></p>
<p>In general, you should always profile your system to see if there are queries that are too slow and consider adding another index to handle those queries. Sometimes a single combined index can be used for multiple queries and others time you will need to make an index for each type of query. Remember that adding indexes slows down modifications to the data so it is possible to have too many indexes. There is always a  trade-off when creating multiple indexes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.prodromus.com/2010/06/14/mysql-should-you-put-an-index-on-a-boolean-field-to-help-query-performance/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

