<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sudarshan Veerasamy on Medium]]></title>
        <description><![CDATA[Stories by Sudarshan Veerasamy on Medium]]></description>
        <link>https://medium.com/@msg2sudan?source=rss-1a8c6751a97a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*N3MCiEJFgz8ubstw8H90FA.jpeg</url>
            <title>Stories by Sudarshan Veerasamy on Medium</title>
            <link>https://medium.com/@msg2sudan?source=rss-1a8c6751a97a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 19:07:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@msg2sudan/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How AI Can Transform Oracle AWR Report Analysis]]></title>
            <link>https://medium.com/@msg2sudan/bridging-oracle-and-ai-creating-an-ai-driven-oracle-awr-report-tool-2c20bfbac76c?source=rss-1a8c6751a97a------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c20bfbac76c</guid>
            <category><![CDATA[performance-tuning]]></category>
            <category><![CDATA[database-administration]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[oracle-database]]></category>
            <category><![CDATA[database-development]]></category>
            <dc:creator><![CDATA[Sudarshan Veerasamy]]></dc:creator>
            <pubDate>Sat, 02 Nov 2024 19:32:12 GMT</pubDate>
            <atom:updated>2024-11-06T08:36:37.751Z</atom:updated>
            <content:encoded><![CDATA[<p>In the world of database management, performance tuning is crucial but often time-consuming. Oracle’s Automatic Workload Repository (AWR) reports contain valuable information, but they can be challenging to interpret due to their complexity and volume.</p><p>What if we could automate this process and use AI to provide instant, in-depth analysis? This article introduces an innovative tool that does just that, combining Oracle database connectivity, AWR report generation, and AI-powered analysis into a user-friendly application.</p><p>The tool combines several powerful technologies: —<strong> Python</strong> for backend logic and data processing — <strong>LangChain</strong> for structuring prompts and interactions with the AI model — <strong>Oracle Database</strong> connectivity for fetching AWR data — <strong>AWS Bedrock</strong> for accessing advanced AI models — <strong>Streamlit</strong> for creating an intuitive web interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lp9WvtfMhB1XSSBBE8GGtA.jpeg" /><figcaption>Oracle AWR Report Analyzer</figcaption></figure><p><strong>Let’s dive into the key components of our application:</strong></p><p>a) Database Connection: First, we create a function for database connection:</p><pre>def connect_to_oracle(connection_details):<br>    try:<br>        connection_string = f&quot;{connection_details[&#39;user&#39;]}/{connection_details[&#39;password&#39;]}@{connection_details[&#39;host&#39;]}:{connection_details[&#39;port&#39;]}/{connection_details[&#39;service_name&#39;]}&quot;<br>        connection = oracledb.connect(connection_string)<br>        return connection<br>    except Exception as e:<br>        st.error(f&quot;Error connecting to Oracle: {str(e)}&quot;)<br>        return None</pre><p>b) Fetching AWR Snapshots</p><pre>def get_snapshots(connection):<br>    try:<br>        query = &quot;&quot;&quot;<br>        SELECT <br>            s.SNAP_ID,<br>            TO_CHAR(s.BEGIN_INTERVAL_TIME, &#39;YYYY-MM-DD HH24:MI:SS&#39;) AS BEGIN_TIME,<br>            TO_CHAR(s.END_INTERVAL_TIME, &#39;YYYY-MM-DD HH24:MI:SS&#39;) AS END_TIME<br>        FROM <br>            DBA_HIST_SNAPSHOT s<br>        ORDER BY <br>            s.SNAP_ID DESC<br>        &quot;&quot;&quot;<br>        df = pd.read_sql(query, connection)<br>        return df<br>    except Exception as e:<br>        st.error(f&quot;Error fetching snapshots: {str(e)}&quot;)<br>        return None</pre><p>c) Generating AWR Reports</p><pre>def generate_awr_report(connection, start_snap_id, end_snap_id, instance_number, db_id):<br>    try:<br>        cursor = connection.cursor()<br>        sql = &quot;&quot;&quot;<br>        SELECT OUTPUT <br>        FROM TABLE(DBMS_WORKLOAD_REPOSITORY.AWR_REPORT_TEXT(<br>            :dbid,<br>            :inst_num,<br>            :start_snap,<br>            :end_snap,<br>            0<br>        ))<br>        &quot;&quot;&quot;<br>        cursor.execute(sql, <br>                       dbid=db_id,<br>                       inst_num=instance_number,<br>                       start_snap=start_snap_id,<br>                       end_snap=end_snap_id)<br>        report_lines = cursor.fetchall()<br>        report_content = &#39;\n&#39;.join(line[0] for line in report_lines if line[0] is not None)<br>        return report_content<br>    except Exception as e:<br>        st.error(f&quot;Error generating AWR report: {str(e)}&quot;)<br>        return None</pre><p>d) AI-Powered Analysis — The heart of our tool is the AI analysis of the AWR report:</p><pre>def analyze_awr_report(awr_report):<br>    prompt = PromptTemplate(<br>        input_variables=[&quot;awr_report&quot;],<br>        template=&quot;&quot;&quot;You are an expert Oracle Database Performance Analyst. Analyze the following AWR report and provide recommendations for improving database performance. <br>Focus on identifying the main performance bottlenecks and suggest specific actions to address them.<br><br>AWR Report:<br>```<br>{awr_report}<br>```<br><br>Please provide your analysis in the following format:<br>1. Summary of Key Performance Indicators<br>2. Main Performance Bottlenecks Identified<br>3. Detailed Recommendations (with explanations)<br>4. Areas Requiring Further Investigation<br><br>Analysis:&quot;&quot;&quot;<br>    )<br>    full_prompt = prompt.format(awr_report=awr_report)<br>    response = llm.invoke(full_prompt)<br>    return response.content</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fn7y8NIOncyVqFAN8oQ3Kg.jpeg" /></figure><p>By leveraging AWS Bedrock and LangChain, our tool provides:</p><p>-Rapid identification of key performance indicators<br>- Pinpointing of major bottlenecks<br>- Detailed, actionable recommendations<br>- Suggestions for areas needing deeper investigation</p><p>I have used anthropic.claude-3-sonnet to analyze AWR report.</p><pre>import boto3<br>import oracledb<br>from langchain_community.chat_models import BedrockChat<br>from langchain.prompts import PromptTemplate<br><br>llm = BedrockChat(<br>    model_id=&quot;anthropic.claude-3-sonnet-20240229-v1:0&quot;,<br>    client=bedrock_client<br>)</pre><p>By combining Oracle database expertise with cutting-edge AI technology, we can significantly improve database performance tuning methods. This approach not only saves time but also provides deeper, more consistent analysis, ultimately leading to better-performing databases and more efficient DBAs.</p><p>Feel free to connect with me on LinkedIn for more in-depth discussions about this tool, Oracle database management, or AI applications in database administration.</p><p><a href="https://www.linkedin.com/in/sudarshan-v-3a6622ba/">https://www.linkedin.com/in/sudarshan-v-3a6622ba/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c20bfbac76c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>