<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>IO on Oracle Scripts</title><link>https://www.oraclescripts.com/tags/io/</link><description>Recent content in IO on Oracle Scripts</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>OracleScripts.com</copyright><lastBuildDate>Tue, 27 Aug 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://www.oraclescripts.com/tags/io/index.xml" rel="self" type="application/rss+xml"/><item><title>Oracle File IO Performance with v$datafile and v$filestat</title><link>https://www.oraclescripts.com/post/oracle-performance-tuning-unlocking-file-io-insights-with-sql/</link><pubDate>Tue, 27 Aug 2024 00:00:00 +0000</pubDate><guid>https://www.oraclescripts.com/post/oracle-performance-tuning-unlocking-file-io-insights-with-sql/</guid><description>
&lt;h2 id="oracle-database-unlocking-file-io-insights-for-performance-tuning"&gt;Oracle Database: Unlocking File I/O Insights for Performance Tuning&lt;/h2&gt;
&lt;h2 id="purpose"&gt;Purpose&lt;/h2&gt;
&lt;p&gt;This Oracle SQL query provides a crucial window into your database's file input/output (I/O) activity. It displays statistics like physical reads, writes, and associated timings for each data file, empowering you to identify I/O bottlenecks and optimize database performance.&lt;/p&gt;
&lt;script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1012089347386563"
crossorigin="anonymous"&gt;&lt;/script&gt;
&lt;ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-1012089347386563"
data-ad-slot="5317081938"
data-ad-format="auto"
data-full-width-responsive="true"&gt;&lt;/ins&gt;
&lt;script&gt;
(adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;
&lt;h2 id="sample-sql-command"&gt;Sample SQL Command&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 1&lt;/span&gt;&lt;span class="cl"&gt;set lines 80 pages 999
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 2&lt;/span&gt;&lt;span class="cl"&gt;col fname heading &amp;#34;File Name&amp;#34; format a60
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 3&lt;/span&gt;&lt;span class="cl"&gt;col sizemb heading &amp;#34;Size(Mb)&amp;#34; format 99,999
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 4&lt;/span&gt;&lt;span class="cl"&gt;col phyrds heading &amp;#34;Reads&amp;#34; format 999,999,999
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 5&lt;/span&gt;&lt;span class="cl"&gt;col readtim heading &amp;#34;Time&amp;#34; format 99.999
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 6&lt;/span&gt;&lt;span class="cl"&gt;col phywrts heading &amp;#34;Writes&amp;#34; format 9,999,999
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 7&lt;/span&gt;&lt;span class="cl"&gt;col writetim heading &amp;#34;Time&amp;#34; format 99.999
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 8&lt;/span&gt;&lt;span class="cl"&gt;select lower(name) fname
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 9&lt;/span&gt;&lt;span class="cl"&gt;, (bytes / 1048576) sizemb
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;10&lt;/span&gt;&lt;span class="cl"&gt;, phyrds
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;11&lt;/span&gt;&lt;span class="cl"&gt;, readtim
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;12&lt;/span&gt;&lt;span class="cl"&gt;, phywrts
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;13&lt;/span&gt;&lt;span class="cl"&gt;, writetim
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;14&lt;/span&gt;&lt;span class="cl"&gt;from v$datafile df
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;15&lt;/span&gt;&lt;span class="cl"&gt;, v$filestat fs
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;16&lt;/span&gt;&lt;span class="cl"&gt;where df.file# = fs.file#
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;17&lt;/span&gt;&lt;span class="cl"&gt;order by 1
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;18&lt;/span&gt;&lt;span class="cl"&gt;/
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="code-breakdown"&gt;Code Breakdown&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;Requires timed_statistics=true&lt;/code&gt;: The initial comment emphasizes the necessity of enabling the &lt;code&gt;timed_statistics&lt;/code&gt; parameter for capturing time-related file I/O metrics.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;set lines 80 pages 999&lt;/code&gt;: Configures output formatting for improved readability.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;col fname heading &amp;quot;File Name&amp;quot; format a60&lt;/code&gt;: Defines a column alias (&lt;code&gt;fname&lt;/code&gt;) with a specific heading and format for the file name.&lt;/li&gt;
&lt;li&gt;Similar &lt;code&gt;col&lt;/code&gt; commands define column aliases, headings, and formats for size, reads, read time, writes, and write time.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;select lower(name) fname, (bytes / 1048576) sizemb, phyrds, readtim, phywrts, writetim&lt;/code&gt;: Selects the following columns:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;lower(name) fname&lt;/code&gt;: Retrieves the data file name in lowercase for consistency.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;(bytes / 1048576) sizemb&lt;/code&gt;: Calculates and displays the file size in megabytes (MB).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;phyrds&lt;/code&gt;: Shows the number of physical reads performed on the file.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;readtim&lt;/code&gt;: Displays the total time spent on physical reads (in seconds).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;phywrts&lt;/code&gt;: Shows the number of physical writes performed on the file.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;writetim&lt;/code&gt;: Displays the total time spent on physical writes (in seconds).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;from v$datafile df, v$filestat fs&lt;/code&gt;: Joins two vital data dictionary views:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;v$datafile&lt;/code&gt;: Contains information about database data files.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;v$filestat&lt;/code&gt;: Provides I/O statistics for data files.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;where df.file# = fs.file#&lt;/code&gt;: Links the two views based on the &lt;code&gt;file#&lt;/code&gt; column, ensuring correct matching of file information and I/O statistics.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;order by 1&lt;/code&gt;: Sorts the results alphabetically by the first column (&lt;code&gt;fname&lt;/code&gt;), making it easier to locate specific files.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/&lt;/code&gt;: The forward slash is essential for executing the query in SQL*Plus or similar command-line tools.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;Key Points:&lt;/strong&gt;&lt;/p&gt;</description></item></channel></rss>