<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Aabishkar Wagle</title>
    <description>The latest articles on DEV Community by Aabishkar Wagle (@aabiseverywhere).</description>
    <link>https://dev.to/aabiseverywhere</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F91077%2F67acb77a-39ba-4652-914c-195cb5400b47.jpg</url>
      <title>DEV Community: Aabishkar Wagle</title>
      <link>https://dev.to/aabiseverywhere</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aabiseverywhere"/>
    <language>en</language>
    <item>
      <title>What is database indexing and how it works</title>
      <dc:creator>Aabishkar Wagle</dc:creator>
      <pubDate>Mon, 28 Sep 2020 17:06:49 +0000</pubDate>
      <link>https://dev.to/aabiseverywhere/what-is-database-indexing-and-how-it-works-3cp1</link>
      <guid>https://dev.to/aabiseverywhere/what-is-database-indexing-and-how-it-works-3cp1</guid>
      <description>&lt;p&gt;Let's say you have a dictionary book containing hundreds of thousands of words. Now, you may need to find the meaning of a word, say 'tenebrous'. What will you do? Will you search from the first page until you find tenebrous, or will you lookup for 't' index in your dictionary book and skip all other words to find the meaning of 'tenebrous'.&lt;/p&gt;

&lt;p&gt;Indexing in the database uses the same concept as indexing in a dictionary book.&lt;/p&gt;

&lt;p&gt;Suppose you have a table called Persons in your database, which has millions of rows containing First and Last Names of millions of Persons. For instance, here's an illustration of a similar table:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;id&lt;/th&gt;
&lt;th&gt;first_name&lt;/th&gt;
&lt;th&gt;last_name&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Ahmed Ahmed&lt;/td&gt;
&lt;td&gt;Khan&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Sam&lt;/td&gt;
&lt;td&gt;Curran&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Sean&lt;/td&gt;
&lt;td&gt;Jordan&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;Jeny&lt;/td&gt;
&lt;td&gt;Stokes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;Robert&lt;/td&gt;
&lt;td&gt;Clarke&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;Patrick&lt;/td&gt;
&lt;td&gt;Cummins&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;.&lt;/td&gt;
&lt;td&gt;...&lt;/td&gt;
&lt;td&gt;...&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1000000&lt;/td&gt;
&lt;td&gt;Luke&lt;/td&gt;
&lt;td&gt;Wright&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Now, without indexing, when you perform a query to search for the person with the first name 'Sean' then your SQL query will look up all the 1 million rows to perform this simple operation. Now, think about how expensive such a simple query can be when data scales to ten million rows. This will be even more expensive when you join another table with another million records.&lt;/p&gt;

&lt;p&gt;Hence, to tackle this issue, the database index comes to help. What indexing will do is sets up the column in sorted order to help in optimizing query performance and searching in a large record.&lt;/p&gt;

&lt;p&gt;For example, if you create an index for the first_name from the above Persons table, which can be done by following SQL query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;create&lt;/span&gt; &lt;span class="k"&gt;index&lt;/span&gt; &lt;span class="n"&gt;person_index&lt;/span&gt; &lt;span class="k"&gt;on&lt;/span&gt; &lt;span class="n"&gt;persons&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;"first_name"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, it will create a separate index named person_index for you in your database and store first_name column of the Persons table in sorted order. Similarly, along with the first_name, the index will also store the memory address of its corresponding column, so that to lookup for the data from other columns of the same row when the search operation is performed.&lt;/p&gt;

&lt;p&gt;Now when you search for a person name 'Sean' in a Persons table, then it will only lookup for the words matching 'S' and will skip other words, just like a human being will search in a dictionary. With this, unnecessary searches can be skipped and the database performance can be boosted.&lt;/p&gt;

&lt;p&gt;I hope this helps somebody.&lt;br&gt;
Thank you.&lt;/p&gt;

</description>
      <category>database</category>
      <category>sql</category>
      <category>postgres</category>
    </item>
    <item>
      <title>Configuring multiple kubeconfig on your machine</title>
      <dc:creator>Aabishkar Wagle</dc:creator>
      <pubDate>Sun, 27 Sep 2020 17:14:21 +0000</pubDate>
      <link>https://dev.to/aabiseverywhere/configuring-multiple-kubeconfig-on-your-machine-59eo</link>
      <guid>https://dev.to/aabiseverywhere/configuring-multiple-kubeconfig-on-your-machine-59eo</guid>
      <description>&lt;p&gt;While working with Kubernetes, probably the best way to access the Kubernetes cluster is by the using kubeconfig file provided by the cloud provider.&lt;/p&gt;

&lt;p&gt;The kubeconfig file is a declarative YAML file which stores the configuration of a Kubernetes cluster. Basically, When you set up a Kubernetes cluster on a cloud, the cloud provider will provide you a kubeconfig file which helps you to get access to the cluster.&lt;/p&gt;

&lt;p&gt;The kubeconfig files should be stored as KUBECONFIG in your bash_profile or else it needs to be under ~./kube/config folder if you are using Linux. This way, when you run kubectl get nodes or any other command then you will get output straight from the configured Kubernetes cluster to your terminal.&lt;/p&gt;

&lt;p&gt;Another approach is to provide a kubeconfig path in every kubectl script you run. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get nodes &lt;span class="nt"&gt;--kubeconfig&lt;/span&gt;&lt;span class="o"&gt;={&lt;/span&gt;kubeconfig_path&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However when you have multiple Kubernetes cluster running on the cloud, then it can be a bit difficult to manage those kubeconfig files, since providing a kubecofig flag to every kubectl script you run can be clumsy, confusing, and difficult to maintain.&lt;/p&gt;

&lt;p&gt;Hence, to solve this issue, we can use the Kubernetes context. &lt;/p&gt;

&lt;p&gt;Suppose if you have multiple Kubernetes clusters running on the cloud and have different kubeconfig files then you can export all those kubeconfig files to the same KUBECONFIG variable, like below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;KUBECONFIG&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/home/aabishkar/Documents/kubernetes/kubeconfig/civo-google-microservice-kubeconfig:/home/aabishkar/Documents/kubernetes/kubeconfig/civo-kubernetes-practise-kubeconfig

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, I have exported the kubeconfig file of two cluster name google-microservice and kubernetes-practice to the same KUBECONFIG variable. &lt;/p&gt;

&lt;p&gt;Now, when I run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl config get-contexts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6oc1v0hpmcn5g4duvjpm.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6oc1v0hpmcn5g4duvjpm.jpg" alt="Kubectl command outputl"&gt;&lt;/a&gt;&lt;br&gt;
This will give me contexts of both dev and prod environments.&lt;br&gt;
Now to switch between different Kubernetes cluster, I just have to use a single command. For example to switch to a dev cluster:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl config use-context google-microservice
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will switch my cluster and I can now access the google-microservice cluster without providing the kubeconfig option to every kubectl script.&lt;/p&gt;

&lt;p&gt;I hope this helps somebody.&lt;br&gt;
Thank you for reading.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>docker</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
