<?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: Abhi</title>
    <description>The latest articles on DEV Community by Abhi (@abhi1).</description>
    <link>https://dev.to/abhi1</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%2F1402970%2F6a53a3cb-a2f1-4b74-bba0-5e98aa511a02.png</url>
      <title>DEV Community: Abhi</title>
      <link>https://dev.to/abhi1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abhi1"/>
    <language>en</language>
    <item>
      <title>Inside the Database: Query To Execution Explained</title>
      <dc:creator>Abhi</dc:creator>
      <pubDate>Tue, 17 Dec 2024 11:56:19 +0000</pubDate>
      <link>https://dev.to/abhi1/inside-the-database-query-to-execution-explained-bjo</link>
      <guid>https://dev.to/abhi1/inside-the-database-query-to-execution-explained-bjo</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkelpaq0dylx66o7w71jw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkelpaq0dylx66o7w71jw.png" alt="Image showing how database works" width="800" height="435"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In this documentation, how a database processes a query from the time it is received in database from the client to its fully execution . The explanation is based on the components shown in the diagram, including the Network Layer, Frontend, Execution Engine, Transaction Management, Concurrency Manager, and Storage Manager.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: I am writing this for my understanding , if you also understood it's a win win. I learned it from YouTube . &lt;a href="https://youtu.be/pPqazMTzNOM?si=17mKps3E7Mx3n1QP&amp;amp;t=236" rel="noopener noreferrer"&gt;SOURCE&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Flow of Execution
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Client to Network Layer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The client sends a request (query) to the database server over a network using a communication protocol like TCP/IP.&lt;br&gt;
The Network Layer is responsible for receiving the incoming query request through network. It manages the connection between the client and the database server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Frontend&lt;/strong&gt;&lt;br&gt;
When client query the database, it is processed by frontend in following stages :&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Tokenizer:&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Breaks the query into smaller components (tokens) for easier processing.&lt;br&gt;
For example, in SELECT * FROM users, tokens are SELECT, &lt;em&gt;, FROM, and users.&lt;br&gt;
*&lt;/em&gt;&lt;em&gt;Parser:&lt;/em&gt;**&lt;br&gt;
Verifies the syntax of the query to ensure it follows the correct format.&lt;br&gt;
If there is an error, the query is rejected, and an error message is sent to the client.&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Optimization:&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
It Generates the execution plan in the most efficient way to execute the query.&lt;br&gt;
The optimizer considers factors like:&lt;br&gt;
Availability of indexes.&lt;br&gt;
How tables are joined or filtered.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Execution by the Execution Engine
The optimized query is passed to the Execution Engine for execution. Here’s what happens:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Query Execution:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Executes the query according to the optimized execution plan.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Cache Manager:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If frequently used data exists in the cache, it is retrieved to speed up execution.&lt;br&gt;
This reduces the need for disk reads, improving performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Utility Services:&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Performs additional tasks such as sorting, aggregating, or formatting the query results.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Transaction Management
&lt;/h2&gt;

&lt;p&gt;If the query involves changes to data (e.g., INSERT, UPDATE, or DELETE), the Transaction Manager ensures the following:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Lock Manager:&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Locks specific rows, tables, or resources to prevent data conflicts during concurrent operations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Recovery Manager:&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Ensures changes are durable and can be recovered in case of a system crash.&lt;br&gt;
Transactions adhere to ACID properties:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Atomicity: All parts of the transaction succeed or fail together.&lt;/li&gt;
&lt;li&gt;Consistency: Ensures data remains in a valid state.&lt;/li&gt;
&lt;li&gt;Isolation: Prevents interference from other transactions.&lt;/li&gt;
&lt;li&gt;Durability: Changes are permanent after a transaction is committed.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  5. Concurrency Management
&lt;/h2&gt;

&lt;p&gt;In a multi-user environment, multiple queries may run simultaneously.&lt;br&gt;
The Concurrency Manager handles:&lt;br&gt;
Parallel Execution: Allowing multiple reads and writes without data conflicts.&lt;br&gt;
Techniques like locking, versioning, or optimistic concurrency control ensure consistency.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Storage Management
&lt;/h2&gt;

&lt;p&gt;The Storage Manager interacts with the underlying storage system to fetch or write data as required:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Disk Storage Manager:&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Reads or writes data to and from the physical disk.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Buffer Manager:&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Temporarily caches data in memory to speed up access to frequently used records.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Index Manager:&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Uses indexes to locate specific rows quickly, avoiding full table scans.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. OS Interaction Layer
&lt;/h2&gt;

&lt;p&gt;The Storage Manager interacts with the Operating System for file I/O operations.&lt;br&gt;
This ensures that data is read or written efficiently to the disk.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Summary of Execution Flow&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Client sends a query → received by Network Layer.&lt;/li&gt;
&lt;li&gt;Frontend processes the query (Tokenization → Parsing → Optimization).&lt;/li&gt;
&lt;li&gt;Execution Engine executes the query, retrieves or manipulates data.&lt;/li&gt;
&lt;li&gt;Transaction Manager ensures data consistency for write operations.&lt;/li&gt;
&lt;li&gt;Concurrency Manager handles simultaneous query execution.&lt;/li&gt;
&lt;li&gt;Storage Manager fetches or writes data from/to storage.&lt;/li&gt;
&lt;li&gt;Results are sent back to the client.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>database</category>
      <category>databaseworking</category>
      <category>databasestructure</category>
    </item>
    <item>
      <title>How to create Custom Hook in React</title>
      <dc:creator>Abhi</dc:creator>
      <pubDate>Mon, 16 Dec 2024 08:38:03 +0000</pubDate>
      <link>https://dev.to/abhi1/how-to-create-custom-hook-in-react-8g8</link>
      <guid>https://dev.to/abhi1/how-to-create-custom-hook-in-react-8g8</guid>
      <description>&lt;p&gt;This post is for beginner who is learning React and want to know how to create custom hooks.&lt;br&gt;
In this example custom hook is created to convert currency using an api. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fokto7eru8k4713hafwp4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fokto7eru8k4713hafwp4.png" alt="Image description" width="720" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://abhishekbhattarai.medium.com/how-to-create-a-custom-hook-in-react-easy-mode-b3a68a2d0023" rel="noopener noreferrer"&gt;Custom hook to convert currency&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>customhook</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
