<?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>OmanDev &#187; database</title>
	<atom:link href="http://www.omandev.net/tag/database/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.omandev.net</link>
	<description>Technical, computer related articles and projects.</description>
	<lastBuildDate>Sat, 17 Jul 2010 18:54:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>تلميحات SQL 1 البحث السريع بدون استخدام like</title>
		<link>http://www.omandev.net/2009/01/%d8%aa%d9%84%d9%85%d9%8a%d8%ad%d8%a7%d8%aa-sql-1-%d8%a7%d9%84%d8%a8%d8%ad%d8%ab-%d8%a7%d9%84%d8%b3%d8%b1%d9%8a%d8%b9-%d8%a8%d8%af%d9%88%d9%86-%d8%a7%d8%b3%d8%aa%d8%ae%d8%af%d8%a7%d9%85-like/</link>
		<comments>http://www.omandev.net/2009/01/%d8%aa%d9%84%d9%85%d9%8a%d8%ad%d8%a7%d8%aa-sql-1-%d8%a7%d9%84%d8%a8%d8%ad%d8%ab-%d8%a7%d9%84%d8%b3%d8%b1%d9%8a%d8%b9-%d8%a8%d8%af%d9%88%d9%86-%d8%a7%d8%b3%d8%aa%d8%ae%d8%af%d8%a7%d9%85-like/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 06:47:00 +0000</pubDate>
		<dc:creator>Ali AL Lawati</dc:creator>
				<category><![CDATA[برمجة و تطوير]]></category>
		<category><![CDATA[عربي]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[تلميحات]]></category>
		<category><![CDATA[قاعدة بيانات]]></category>

		<guid isPermaLink="false">http://66.147.242.194/~omandevn/wrd1/wordpress/?p=86</guid>
		<description><![CDATA[السلام عليكم و رحمة الله و بركاته ، صارت فترة طويلة لم يكتب شيء في هذا الجزء من المدونة و هذا غالبا بسبب كسلي  
فكرت اضع بعض تلميحات ال اس كيو ال SQL  كون لا بد لأي مبرمج في هذه الفترة ان يستخدمها لكي يتصل بقاعدة بياناته
هنالك الكثير من الحركات الجميلة في هذه [...]


Related posts:<ol><li><a href='http://www.omandev.net/2007/07/sqltip1-search-database-faster-without-like/' rel='bookmark' title='Permanent Link: SQLTip1: search database faster without like'>SQLTip1: search database faster without like</a></li>
<li><a href='http://www.omandev.net/2008/08/%d8%aa%d9%84%d9%85%d9%8a%d8%ad%d8%a7%d8%aa-%d9%81%d9%8a-%d8%a7%d9%84%d9%84%d9%8a%d9%86%d9%83%d8%b3/' rel='bookmark' title='Permanent Link: تلميحات في اللينكس'>تلميحات في اللينكس</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div dir="rtl" style="text-align: right;">السلام عليكم و رحمة الله و بركاته ، صارت فترة طويلة لم يكتب شيء في هذا الجزء من المدونة و هذا غالبا بسبب كسلي <img src='http://www.omandev.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>فكرت اضع بعض تلميحات ال اس كيو ال SQL  كون لا بد لأي مبرمج في هذه الفترة ان يستخدمها لكي يتصل بقاعدة بياناته</p>
<p>هنالك الكثير من الحركات الجميلة في هذه اللغة التي نغفل عنها لقلة وقت الإطلاع و هذه أحد تلك الحركات</p>
<p> البحث السريع دون استخدام  like</p>
<p> في حالة اذا كان لدينا في احد جداول قاعدة البيانات عمود يحتوي على نص طويل مثلا نص قصة أو مثلا تدوينة أو رسالة او موضوع منتدى  طبعا هذا النص سيتكون من العديد من الكلمات &#8211; الآلاف منها &#8212; .</p>
<p>في حين الحاجة للبحث سنبحث عن كلمة معينة في جميع نصوص مواضيع المنتديات مثلا . فأسهل طريقة لعمل ذلك هي
<div style="text-align: left;"><span style="font-weight: bold;">&#8220;Select title from articles where body like &#8216;%database%&#8217;&#8221;</span><br /><span style="font-weight: bold;"></span></div>
<p><span style="font-weight: bold;"><br />ولكن ماذا لو كان لدينا الكثير من المواضيع (بالتالي رفوف كثيرة بالملاين في جدول الـ articles  ) حينها سيصبح البحث بطيئا جدا<br />فاذا كان الهدف من البحث لديك هو الوصول للنتيجة بأسرع طريقة فهذه إحدى الطرق التي اجدها جيدة في الـ MYSQL <br />أولا عليك جعل جدول الـ articles  من نوع الـ </span>MyIsam<br />ثانيا : علينا اضافة خاصية ارضفة للعمود body  و ذلك بالأمر التالي
<div style="text-align: left;">ALTER TABLE  articles ADD FULLTEXT(body);</div>
<p>الآن حين البحث اذا استعملنا الاستعلام التالي  الذي يبحث عن كلمة database  في عمود الـ body من جدول الـ</p>
<p><span style="font-weight: bold;">&#8220;select title , MATCH (body) AGAINST (&#8216;database&#8217;)  as rank from articles  ORDER BY rank desc;&#8221;</p>
<p>سنحصل على نتيجة مثل :</p>
<p></span>
<div style="text-align: left;">|title      | rank   |<br />&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />|sqltip   | 1.3      |<br />| eclipse| 0            |<br />|.NET    | 0        |</p>
<div style="text-align: right;">هنا الرانك عبارة عن مدى تطابق النتيجة اثناء البحث وكلما كان اكبر كلما دل على تطابق اكثر طبعا الصفر تعني عدم الحصول على الكلمة في النص و يمككنا عدم اظهار النتائج التي تحتوي على صفر بالاستعلام التالي</p>
<p>&#8220;select title , MATCH (body) AGAINST (&#8216;database&#8217;) as rank from articles where MATCH (body) AGAINST (&#8216;database&#8217;) > 0  ORDER BY rank desc;&#8221;</p>
<p>اتمنى ان تكون هذه التلميحة مفيدة لكم</p>
<p>لرؤية التدوينة في نسختها الانجليزية تفضل <a href="http://www.omandev.net/2007/07/sqltip1-search-database-faster-without.html">هنا </a></div>
<p><span style="font-weight: bold;"></span></div>
<p></div>
<div class="blogger-post-footer">Omandev.net Arabic feed</div>


<p>Related posts:<ol><li><a href='http://www.omandev.net/2007/07/sqltip1-search-database-faster-without-like/' rel='bookmark' title='Permanent Link: SQLTip1: search database faster without like'>SQLTip1: search database faster without like</a></li>
<li><a href='http://www.omandev.net/2008/08/%d8%aa%d9%84%d9%85%d9%8a%d8%ad%d8%a7%d8%aa-%d9%81%d9%8a-%d8%a7%d9%84%d9%84%d9%8a%d9%86%d9%83%d8%b3/' rel='bookmark' title='Permanent Link: تلميحات في اللينكس'>تلميحات في اللينكس</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.omandev.net/2009/01/%d8%aa%d9%84%d9%85%d9%8a%d8%ad%d8%a7%d8%aa-sql-1-%d8%a7%d9%84%d8%a8%d8%ad%d8%ab-%d8%a7%d9%84%d8%b3%d8%b1%d9%8a%d8%b9-%d8%a8%d8%af%d9%88%d9%86-%d8%a7%d8%b3%d8%aa%d8%ae%d8%af%d8%a7%d9%85-like/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Increasing performance and adding flexibility using arrays instead of recordsets in ASP with databases</title>
		<link>http://www.omandev.net/2008/08/increasing-performance-and-adding-flexibility-using-arrays-instead-of-recordsets-in-asp-with-databases/</link>
		<comments>http://www.omandev.net/2008/08/increasing-performance-and-adding-flexibility-using-arrays-instead-of-recordsets-in-asp-with-databases/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 13:24:00 +0000</pubDate>
		<dc:creator>Arkan Hadi</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[ADO]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[recordset]]></category>
		<category><![CDATA[rs]]></category>
		<category><![CDATA[server-side]]></category>
		<category><![CDATA[vbscript]]></category>

		<guid isPermaLink="false">http://66.147.242.194/~omandevn/wrd1/wordpress/?p=36</guid>
		<description><![CDATA[
  

Those days, inorder to increase the websites/intranets features and interactivity it is essential to have a connectivity to a database wither its an oracle database or MS access or other types of databases, .. and with databases comes the issue of performance, so in this article i would like to share some of [...]


Related posts:<ol><li><a href='http://www.omandev.net/2008/08/adding-a-friendly-splash-waiting-screen-while-the-code-is-being-executed-in-asp/' rel='bookmark' title='Permanent Link: Adding a friendly splash (waiting screen) while the code is being executed in ASP'>Adding a friendly splash (waiting screen) while the code is being executed in ASP</a></li>
<li><a href='http://www.omandev.net/2007/07/sqltip1-search-database-faster-without-like/' rel='bookmark' title='Permanent Link: SQLTip1: search database faster without like'>SQLTip1: search database faster without like</a></li>
<li><a href='http://www.omandev.net/2010/03/exchange-2010-dag-problem/' rel='bookmark' title='Permanent Link: Exchange 2010 DAG problem?'>Exchange 2010 DAG problem?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<link rel="File-List" href="file:///C:%5CDOCUME%7E1%5Cuser%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"><!--[if gte mso 9]><xml>  <w:worddocument>   <w:view>Normal</w:View>   <w:zoom>0</w:Zoom>   <w:punctuationkerning/>   <w:validateagainstschemas/>   <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid>   <w:ignoremixedcontent>false</w:IgnoreMixedContent>   <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText>   <w:compatibility>    <w:breakwrappedtables/>    <w:snaptogridincell/>    <w:wraptextwithpunct/>    <w:useasianbreakrules/>    <w:dontgrowautofit/>   </w:Compatibility>   <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel>  </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml>  <w:latentstyles deflockedstate="false" latentstylecount="156">  </w:LatentStyles> </xml><![endif]--><br />
<style> <!--  /* Font Definitions */  @font-face 	{font-family:serif; 	panose-1:0 0 0 0 0 0 0 0 0 0; 	mso-font-alt:"Times New Roman"; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-format:other; 	mso-font-pitch:auto; 	mso-font-signature:0 0 0 0 0 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:4.3pt; 	mso-pagination:none; 	mso-hyphenate:none; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-language:#00FF;} p.MsoBodyText, li.MsoBodyText, div.MsoBodyText 	{margin-top:4.3pt; 	margin-right:4.3pt; 	margin-bottom:6.0pt; 	margin-left:4.3pt; 	mso-pagination:none; 	mso-hyphenate:none; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-language:#00FF;} p.TableContents, li.TableContents, div.TableContents 	{mso-style-name:"Table Contents"; 	mso-style-parent:"Body Text"; 	margin:0cm; 	margin-bottom:.0001pt; 	mso-pagination:none; 	mso-hyphenate:none; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-language:#00FF;} @page Section1 	{size:612.0pt 792.0pt; 	margin:1.0cm 1.0cm 1.0cm 2.0cm; 	mso-header-margin:1.0cm; 	mso-footer-margin:1.0cm; 	mso-paper-source:0;} div.Section1 	{page:Section1; 	mso-footnote-position:beneath-text;} --> </style>
<p><!--[if gte mso 10]><br />
<style>  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0cm 5.4pt 0cm 5.4pt; 	mso-para-margin:0cm; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} </style>
<p> <![endif]-->
<p class="MsoNormal" style="margin: 0cm 0cm 12pt;"><span style="">Those days</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >, inord</span><span style="">er to increase the websites/intranets features and interactivity it is essential to have a connectivity to a database wither its an oracle database or MS access or other types of databases, .. and with databases comes the issue of performance, so in this article i would like to share some of the things that a developer can do t</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >o maint</span><span style="">ain a reasonable performance and even adding mor</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >e flexibil</span><span style="">ity to the ASP code dealing with databases that has huge data that needs to be fetched.</p>
<p>in this article am usin</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >g vbscri</span><span style="">pt as a server-side script.</p>
<p>for convenience i will show the steps on how to connect to MS access database first and after that i will start on the tweaks that developers can do in the coding to enhance performance and adding flexibility <o:p></o:p></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0.0001pt;"><b><span style=";font-family:&quot;;font-size:10;"  ><% <o:p></o:p></span></b></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0.0001pt;"><b><span style=";font-family:&quot;;font-size:10;"  >dim conn<br />
<br />set conn=Server.CreateObject(&#8220;ADODB.Connection&#8221;)<br />
<br />conn.Provider=&#8221;Microsoft.Jet.OLEDB.4.0&#8243;<br />
<br />conn.Open &#8220;c:YOUR_DATABASENAME.mdb&#8221; <o:p></o:p></span></b></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0.0001pt;"><b><span style=";font-family:&quot;;font-size:10;"  >%><o:p></o:p></span></b></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0.0001pt;"><span style=""><br />
<br />first of all, after you set up </span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >a connectivity</span><span style=""> to th</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >e databa</span><span style="">se, you create a query, for example:</p>
<p><b><% <o:p></o:p></b></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0.0001pt;"><b><span style="">dim rs &#8216;recored set <o:p></o:p></span></b></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0.0001pt;"><b><span style=";font-family:&quot;;font-size:10;"  >set rs=Server.CreateObject(&#8220;ADODB.recordset&#8221;)<br />
<br />rs.Open &#8220;Select * from TABLE_NAME&#8221;, conn<o:p></o:p></span></b></p>
<p class="TableContents" style="margin-bottom: 0.75pt;"><b><span style="">%></span></b><span style=""></p>
<p>at this point not much can be done, connecting to the database and querying to get data is pretty much fixed.</span></p>
<p class="TableContents" style="margin-bottom: 0.75pt;"><span style="">the thing start when manipulating the data we just fetched, most of the people do is manipulating the data like the following code</p>
<p><b><% <o:p></o:p></b></span></p>
<p class="TableContents" style="margin-bottom: 0.75pt;"><b><span style="">do while not rs.EOF<br />
<br />&#8216; manipulate data here, go through the query exucuted, movenext, movelast move previous, etc</p>
<p>response.write(rs(&#8220;FIELD_NAME&#8221;))<br />
<br />rs.MoveNext<br />
<br />loop<br />
<br />rs.Close<br />
<br />conn.Close<br />
<br />set rs=nothing<br />
<br />set conn=nothing<o:p></o:p></span></b></p>
<p class="TableContents" style="margin-bottom: 0.75pt;"><b><span style=""><span style=""> </span>%><br />
<br /></span></b><span style=""></p>
<p>the above code would work perfectly if you have to deal with one query, relatively small data set in the query,  and only small code is used to manipulate the recordset, and as long as you want to deal with the data (in the above code) th</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >e records</span><span style="">et should stay open</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" ></span><span style=""> .. what if we wanted to do a new query while we are dealing with the existing one while it is still not closed? .. we would have to create another record set and set it and open connection to it, and this would make a nightmare interms of performance if we have a larg data and multiple quieries to deal with. to avoid this we can copy the query information to a multi-dimensional array and close th</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >e records</span><span style="">et so we can use it again while we are working with the existing data. instead of doing the previous code we can do the following code:</p>
<p><b><% <o:p></o:p></b></span></p>
<p class="TableContents" style="margin-bottom: 0.75pt;"><b><span style="">dim rsArray</p>
<p>rsArray=rs.getrows()<br />
<br />rs.close<br />
<br />for i=0 to UBound(rsArray,2)-1<br />
<br />&#8216; &#8230;. work with the data here using a multi-dim array, its easier and faster, we can even<br />
<br />&#8216;use another query with the same recordset, ..<br />
<br />&#8216; we can work with the old data and with the new query data without creating new record set</p>
<p>next<br />
<br />conn.Close<br />
<br />set rs=nothing<br />
<br />set conn=nothing <o:p></o:p></span></b></p>
<p class="TableContents" style="margin-bottom: 0.75pt;"><b><span style="">%></span></b><span style=""></p>
<p>after we fetched the information we needed into &#8220;rsArray&#8221; we finished from the record set and we closed it &#8220;rs.close&#8221; so we can use it later while dealing with the existing data without having to create a new recordset. now while we have </span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >a multi dimensio</span><span style="">nal array in our hand, we can take advantage of that to ou</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >r bene</span><span style="">fit, even we ca</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >n red</span><span style="">im it if we want to add ne</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >w colum</span><span style="">ns or rows, but whe</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >n redim-i</span><span style="">ng the data is lost, so we have to use &#8220;preserve&#8221; keyword to preserve the data after rediming, for example if we have number of rows and we want to add a new one we do the following code<br />
<br /><b><br />
<br /><%</b></span></p>
<p class="TableContents" style="margin-bottom: 0.75pt;">.</p>
<p class="TableContents" style="margin-bottom: 0.75pt;">.</p>
<p class="TableContents" style="margin-bottom: 0.75pt;">.<br />
<br /><span style=""><b><o:p></o:p></b></span></p>
<p class="TableContents" style="margin-bottom: 0.75pt;"><b><span style="">dim cols</p>
<p>dim rows</p>
<p>cols = UBound(rsArray,1) +1</p>
<p>rows = UBound(rsArray,2) +1</p>
<p>redim preserve rsArray(cols,rows+1)  &#8216; we have extra row<br />
<br />%><br />
<br /></span></b><span style=""></p>
<p>notice the preserve keyword only works whe</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >n redim-i</span><span style="">ng the las</span><span style="border: 1pt none windowtext; padding: 0cm;font-family:serif;" >t dimension</span><span style="">, if we want to redim the first one (or the second one or third if we have more then 2) we have to go around it, copying the array to another array and put the dimension we want to change in the last place, and then we can use the &#8220;redim preserve&#8221; and work with the temp. array.</p>
<p>As a conclusion, </span><span style="">using the actual record sets while manipulating data and creating new ones whenever we need is not efficient, on the other hand </span><span style="">knowing the features of the arrays we can use it to our advantage so dealing with arrays is more flexible and more efficient then the actual record set.</span><span style="font-family:Arial;"><o:p></o:p></span></p>
<div class="blogger-post-footer">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
omandev.net English feed</div>


<p>Related posts:<ol><li><a href='http://www.omandev.net/2008/08/adding-a-friendly-splash-waiting-screen-while-the-code-is-being-executed-in-asp/' rel='bookmark' title='Permanent Link: Adding a friendly splash (waiting screen) while the code is being executed in ASP'>Adding a friendly splash (waiting screen) while the code is being executed in ASP</a></li>
<li><a href='http://www.omandev.net/2007/07/sqltip1-search-database-faster-without-like/' rel='bookmark' title='Permanent Link: SQLTip1: search database faster without like'>SQLTip1: search database faster without like</a></li>
<li><a href='http://www.omandev.net/2010/03/exchange-2010-dag-problem/' rel='bookmark' title='Permanent Link: Exchange 2010 DAG problem?'>Exchange 2010 DAG problem?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.omandev.net/2008/08/increasing-performance-and-adding-flexibility-using-arrays-instead-of-recordsets-in-asp-with-databases/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
