Optimization, etc - Mailing list pgsql-sql

From Jeff Sack
Subject Optimization, etc
Date
Msg-id 005101c168e9$a7aac5a0$019ca8c0@jeff
Whole thread Raw
In response to Re: transposing data for a view  ("Josh Berkus" <josh@agliodbs.com>)
Responses Re: Optimization, etc
List pgsql-sql
<div class="Section1"><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">(apologies if this was sent twice)</span></font><p class="MsoNormal"><font face="Arial"
size="2"><spanstyle="font-size:10.0pt; 
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">Hello all.<span style="mso-spacerun:yes">  </span>I have an academic project that I’m working on
and,as I’m relatively new to optimization techniques and database design, I’m wondering if some of you can give me some
pointers.<spanstyle="mso-spacerun:yes">  </span>Below is the schema (to model baseball statistics), and I’m pretty much
stuckwith it at this point.<span style="mso-spacerun:yes">  </span>If anyone has any suggestions involving changing the
schema,I’d appreciate hearing them just for future reference…</span></font><p class="MsoNormal"><font face="Arial"
size="2"><spanstyle="font-size:10.0pt; 
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">There are several interesting queries that I’ve been constructing just to get a feel for this
schema,and given that some of these tables contain 100,000-200,000 <span class="SpellE">tuples</span>, some queries are
takinga good 5-10 seconds to execute.<span style="mso-spacerun:yes">  </span>I’m just wondering if this is simply the
faultof my schema or are these queries poorly constructed?<span style="mso-spacerun:yes">  </span>Here are some queries
I’vebeen trying:</span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">Here’s a query for the top ten all time home run leaders:</span></font><p class="MsoNormal"><span
class="GramE"><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:Arial">select</span></font></span><fontface="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
Arial"> <span class="SpellE">P.first_name</span>, <span class="SpellE">P.last_name</span>, <span
class="SpellE">S.player_id</span>,sum(<span class="SpellE">B.hr</span>) as hr, (sum(<span
class="SpellE">B.h</span>)::float/ sum(<span class="SpellE">B.ab</span>)::float) <span
class="SpellE">ab</span></span></font><pclass="MsoNormal"><span class="GramE"><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:Arial">from</span></font></span><fontface="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
Arial"> statistics S, <span class="SpellE">batting_stats</span> B, players P</span></font><p class="MsoNormal"><span
class="GramE"><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:Arial">where</span></font></span><fontface="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
Arial"> <span class="SpellE">S.id</span>=<span class="SpellE">B.id</span> and <span
class="SpellE">S.player_id</span>=<spanclass="SpellE">P.id</span> and <span
class="SpellE">B.ab</span>>0</span></font><pclass="MsoNormal"><span class="GramE"><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:Arial">group</span></font></span><fontface="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
Arial"> by <span class="SpellE">P.first_name</span>, <span class="SpellE">P.last_name</span>, <span
class="SpellE">S.player_id</span></span></font><pclass="MsoNormal"><span class="GramE"><font face="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family:Arial">order</span></font></span><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
Arial"> by hr <span class="SpellE">desc</span> limit 10;</span></font><p class="MsoNormal"><font face="System"
size="2"><spanstyle="font-size:10.0pt; 
font-family:System;mso-bidi-font-family:Arial"> </span></font><p class="MsoNormal"
style="mso-layout-grid-align:none"><fontface="Arial" size="2"><span style="font-size:10.0pt;font-family:Arial">Select
the10 highest batting averages of all time where the batter had 600 or more at bats.<span style="mso-spacerun:yes"> 
</span>Alsogather the name, year, team, hits, at bats...</span></font><p class="MsoNormal"
style="mso-layout-grid-align:none"><fontface="Courier New" size="2"><span style="font-size:10.0pt;font-family:"Courier
New""> </span></font><pclass="MsoNormal" style="mso-layout-grid-align:none"><span class="GramE"><font face="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
"Courier New"">select</span></font></span><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:"CourierNew""> (<span class="SpellE">B.h::float</span>
/<span class="SpellE">B.ab</span>) as <span class="SpellE">avg</span>, <span class="SpellE">B.h</span>, <span
class="SpellE">B.ab</span>,<span class="SpellE">S.year</span>, <span class="SpellE">P.first_name</span>, <span
class="SpellE">P.last_name</span>,<span class="SpellE">T.city</span>, <span class="SpellE">T.name</span>
</span></font><pclass="MsoNormal" style="mso-layout-grid-align:none"><span class="GramE"><font face="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
"Courier New"">from</span></font></span><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:"CourierNew""> <span
class="SpellE">batting_stats</span>B, statistics S, players P, Teams T </span></font><p class="MsoNormal"
style="mso-layout-grid-align:none"><spanclass="GramE"><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
"Courier New"">where</span></font></span><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:"CourierNew""> <span class="SpellE">B.ab</span> >
600and <span class="SpellE">S.id</span>=<span class="SpellE">B.id</span> and <span
class="SpellE">S.player_id</span>=<spanclass="SpellE">P.id</span> and <span class="SpellE">S.team_id</span>=<span
class="SpellE">T.id</span></span></font><p class="MsoNormal" style="mso-layout-grid-align:none"><span
class="GramE"><fontface="System" size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
"Courier New"">order</span></font></span><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:"CourierNew""> by <span class="SpellE">avg</span> <span
class="SpellE">desc</span>limit 10;</span></font><p class="MsoNormal"><font face="System" size="2"><span
style="font-size:10.0pt;
font-family:System;mso-bidi-font-family:Arial"> </span></font><p class="MsoNormal"
style="mso-layout-grid-align:none"><fontface="Arial" size="2"><span style="font-size:10.0pt;font-family:Arial">To find
thenames of the single season home run leaders, along with the total number of home runs, the team name/city and the
year:</span></font><pclass="MsoNormal" style="mso-layout-grid-align:none"><font face="Courier New" size="2"><span
style="font-size:10.0pt;font-family:"CourierNew""> </span></font><p class="MsoNormal"
style="mso-layout-grid-align:none"><spanclass="GramE"><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
"Courier New"">select</span></font></span><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:"CourierNew""> <span
class="SpellE">P.first_name</span>,<span class="SpellE">P.last_name</span>, <span class="SpellE">B.hr</span>, <span
class="SpellE">T.name</span>,<span class="SpellE">T.city</span>, <span class="SpellE">S.year</span> from statistics S,
<spanclass="SpellE">batting_stats</span> B, players P, teams T </span></font><p class="MsoNormal"
style="mso-layout-grid-align:none"><spanclass="GramE"><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
"Courier New"">where</span></font></span><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:"CourierNew""> (<span class="SpellE">S.id</span>=<span
class="SpellE">B.id</span>)and </span></font><p class="MsoNormal" style="mso-layout-grid-align:none"><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family:"Courier New"">(<span
class="SpellE">S.player_id</span>=<spanclass="SpellE">P.id</span>) and </span></font><p class="MsoNormal"
style="mso-layout-grid-align:none"><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:"CourierNew"">(<span class="SpellE">B.hr</span>>30)
and</span></font><pclass="MsoNormal" style="mso-layout-grid-align:none"><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:"CourierNew"">(<span class="SpellE">T.id</span>=<span
class="SpellE">S.team_id</span>)limit 10;</span></font><p class="MsoNormal" style="mso-layout-grid-align:none"><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family:"Courier
New""> </span></font><pclass="MsoNormal" style="mso-layout-grid-align:none"><font face="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial">Youget the idea.<span style="mso-spacerun:yes">  </span>These queries take a
while.<spanstyle="mso-spacerun:yes">  </span>Is this just the way it is or there things that can be done to optimize
this?<spanstyle="mso-spacerun:yes">  </span></span></font><p class="MsoNormal" style="mso-layout-grid-align:none"><font
face="Arial"size="2"><span style="font-size:10.0pt;font-family:Arial"> </span></font><p class="MsoNormal"
style="mso-layout-grid-align:none"><fontface="Arial" size="2"><span style="font-size:10.0pt;font-family:Arial">One
separateissue (the reason why the above examples are all about batting statistics) I’m having is representing the
inningspitched statistic.<span style="mso-spacerun:yes">  </span>The way it is often represented (and the way it is
donein this schema) is something like this 123.0 means exactly 123 innings pitched, 123.1 means 123 1/3 innings, and
123.2means 123 2/3 innings pitched.<span style="mso-spacerun:yes">  </span>I’m contemplating the best way to write a
functionthat knows how to sum these values accurately.<span style="mso-spacerun:yes">  </span>Is this something that
canbe done with PL/PGSQL or should I go straight to something like PLPERL?<span style="mso-spacerun:yes"> 
</span>Alternatively,I could research a way to represent fractions in the DB and write a script to convert all values
inthis column.<span style="mso-spacerun:yes">  </span><span class="GramE">Any advice here??</span></span></font><p
class="MsoNormal"style="mso-layout-grid-align:none"><font face="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial"> </span></font><pclass="MsoNormal" style="mso-layout-grid-align:none"><font
face="Arial"size="2"><span style="font-size:10.0pt;font-family:Arial">Thanks in advance for any thoughts, comments,
suggestions…</span></font><pclass="MsoNormal" style="mso-layout-grid-align:none"><font face="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial"> </span></font><pclass="MsoNormal" style="mso-layout-grid-align:none"><font
face="Arial"size="2"><span style="font-size:10.0pt;font-family:Arial">-Jeff</span></font><div
style="border:none;border-bottom:solidwindowtext 1.0pt;mso-border-bottom-alt: 
solid windowtext .75pt;padding:0in 0in 1.0pt 0in"><p class="MsoNormal" style="border:none;mso-border-bottom-alt:solid
windowtext.75pt; 
padding:0in;mso-padding-alt:0in 0in 1.0pt 0in"><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:Arial"> </span></font></div><p
class="MsoNormal"><b><fontface="System" size="2"><span style="font-size:10.0pt; 
font-family:System;mso-bidi-font-family:System;font-weight:bold"> </span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><spanclass="GramE"><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold">create</span></font></b></span><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"> table leagues</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold">(</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span>-- create an integer id field for easier and
efficientFK referencing</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">id</span><span
style="mso-tab-count:2">                    </span>serial,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">name</span><span
style="mso-tab-count:2">              </span><span class="SpellE">varchar</span>(50),</span></font></b><p
class="MsoNormal"style="mso-layout-grid-align:none"><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="SpellE"><span
class="GramE">first_year</span></span><spanstyle="mso-tab-count: 
1">         </span>integer not null </span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:2">                        </span><span class="GramE">check</span>
(<spanclass="SpellE">first_year</span> > 1850 and <span class="SpellE">first_year</span> <
2010),</span></font></b><pclass="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="SpellE"><span
class="GramE">last_year</span></span><spanstyle="mso-tab-count: 
1">         </span>integer</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:2">                        </span><span class="GramE">check</span>
(<spanclass="SpellE">first_year</span> > 1850 and <span class="SpellE">first_year</span> <
2010),</span></font></b><pclass="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">primary</span>
key(id),</span></font></b><pclass="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">constraint</span> <span
class="SpellE">chronological_order</span></span></font></b><pclass="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:2">                        </span><span class="GramE">check</span>
(<spanclass="SpellE">last_year</span> >= <span class="SpellE">first_year</span>)</span></font></b><p
class="MsoNormal"style="mso-layout-grid-align:none"><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold">);</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"> </span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"> </span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><span
class="GramE"><b><fontface="System" size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold">create</span></font></b></span><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"> table teams</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold">(</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">id</span><span
style="mso-tab-count:2">                    </span>serial,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">name</span><span
style="mso-tab-count:2">              </span><span class="SpellE">varchar</span>(50) not null,</span></font></b><p
class="MsoNormal"style="mso-layout-grid-align:none"><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">city</span><span
style="mso-tab-count:2">                 </span><span class="SpellE">varchar</span>(50),</span></font></b><p
class="MsoNormal"style="mso-layout-grid-align:none"><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="SpellE"><span
class="GramE">first_year</span></span><spanstyle="mso-tab-count: 
1">         </span>integer not null</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:2">                        </span><span class="GramE">check</span>
(<spanclass="SpellE">first_year</span> > 1850 and <span class="SpellE">first_year</span> <
2010),</span></font></b><pclass="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="SpellE"><span
class="GramE">last_year</span></span><spanstyle="mso-tab-count: 
1">         </span>integer</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:2">                        </span><span class="GramE">check</span>
(<spanclass="SpellE">first_year</span> > 1850 and <span class="SpellE">first_year</span> <
2010),</span></font></b><pclass="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="SpellE"><span
class="GramE">alt_id</span></span><spanstyle="mso-tab-count: 
2">               </span>integer,</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="SpellE"><span
class="GramE">league_id</span></span><spanstyle="mso-tab-count: 
1">        </span>integer not null,</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">primary</span>
key(id),</span></font></b><pclass="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">foreign</span> key(<span
class="SpellE">alt_id</span>)references teams(id),</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">foreign</span> key(<span
class="SpellE">league_id</span>)references leagues(id)</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:2">                        </span><span class="GramE">on</span>
deletecascade,</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">constraint</span> <span
class="SpellE">chronological_order</span></span></font></b><pclass="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:2">                        </span><span class="GramE">check</span>
(<spanclass="SpellE">last_year</span> >= <span class="SpellE">first_year</span>)</span></font></b><p
class="MsoNormal"style="mso-layout-grid-align:none"><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold">);</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"> </span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><span
class="GramE"><b><fontface="System" size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold">create</span></font></b></span><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"> table players</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold">(</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">id</span><span
style="mso-tab-count:2">                    </span>serial,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="SpellE"><span
class="GramE">first_name</span></span><spanstyle="mso-tab-count: 
1">       </span><span class="SpellE">varchar</span>(30),</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="SpellE"><span
class="GramE">last_name</span></span><spanstyle="mso-tab-count: 
1">       </span><span class="SpellE">varchar</span>(30) not null,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">bats</span><span
style="mso-tab-count:2">                </span>char(1) check (bats in ('L','R','S')),</span></font></b><p
class="MsoNormal"style="mso-layout-grid-align:none"><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">throws</span><span
style="mso-tab-count:2">            </span>char(1) check (throws in ('L','R')),</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="SpellE"><span
class="GramE">dob</span></span><spanstyle="mso-tab-count: 
2">                  </span>date,</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">primary</span>
key(id)</span></font></b><pclass="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold">);</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"> </span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><span
class="GramE"><b><fontface="System" size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold">create</span></font></b></span><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"> table statistics</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold">(</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">id</span><span
style="mso-tab-count:3">                                </span>serial,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">year</span><span
style="mso-tab-count:3">                            </span>integer not null,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">g</span><span
style="mso-tab-count:3">                                 </span>integer,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="SpellE"><span
class="GramE">player_id</span></span><spanstyle="mso-tab-count: 
2">                     </span>integer not null,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="SpellE"><span
class="GramE">team_id</span></span><spanstyle="mso-tab-count: 
3">                                   </span>integer not null,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">foreign</span> key(<span
class="SpellE">player_id</span>)references players(id)</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:2">                        </span><span class="GramE">on</span>
deletecascade,</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">foreign</span> key(<span
class="SpellE">team_id</span>)references teams(id)</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:2">                        </span><span class="GramE">on</span>
deletecascade,</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">primary</span>
key(id)</span></font></b><pclass="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold">);</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"> </span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><span
class="GramE"><b><fontface="System" size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold">create</span></font></b></span><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"> table <span class="SpellE">managing_stats</span></span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold">(</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">id</span><span
style="mso-tab-count:3">                                </span>integer not null,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">w</span><span
style="mso-tab-count:3">                                 </span>integer,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">l</span><span
style="mso-tab-count:3">                                  </span>integer,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">primary</span>
key(id),</span></font></b><pclass="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">foreign</span> key(id)
referencesstatistics(id)</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:2">                        </span><span class="GramE">on</span>
deletecascade</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold">);</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"> </span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><span
class="GramE"><b><fontface="System" size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold">create</span></font></b></span><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"> table <span class="SpellE">fielding_stats</span></span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold">(</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">id</span><span
style="mso-tab-count:3">                                </span>integer not null,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">pos</span><span
style="mso-tab-count:3">                             </span>char(5),</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="SpellE"><span
class="GramE">po</span></span><spanstyle="mso-tab-count:3">                               
</span>integer,</span></font></b><pclass="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">a</span><span
style="mso-tab-count:3">                                 </span>integer,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">e</span><span
style="mso-tab-count:3">                                 </span>integer,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="SpellE"><span
class="GramE">dp</span></span><spanstyle="mso-tab-count:3">                               
</span>integer,</span></font></b><pclass="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">primary</span>
key(id),</span></font></b><pclass="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">foreign</span> key(id)
referencesstatistics(id)</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:2">                        </span><span class="GramE">on</span>
deletecascade</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold">);</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"> </span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><span
class="GramE"><b><fontface="System" size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold">create</span></font></b></span><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"> table <span class="SpellE">batting_stats</span></span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold">(</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">id</span><span
style="mso-tab-count:3">                                </span>integer not null,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="SpellE"><span
class="GramE">ab</span></span><spanstyle="mso-tab-count:3">                               
</span>integer,</span></font></b><pclass="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">r</span><span
style="mso-tab-count:3">                                  </span>integer,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">h</span><span
style="mso-tab-count:3">                                 </span>integer,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">doubles</span><span
style="mso-tab-count:3">                                  </span>integer,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">triples</span><span
style="mso-tab-count:3">                         </span>integer,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">hr</span><span
style="mso-tab-count:3">                                </span>integer,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="SpellE"><span
class="GramE">rbi</span></span><spanstyle="mso-tab-count: 
3">                                </span>integer,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="SpellE"><span
class="GramE">sb</span></span><spanstyle="mso-tab-count:3">                               
</span>integer,</span></font></b><pclass="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="SpellE"><span
class="GramE">cs</span></span><spanstyle="mso-tab-count:3">                               
</span>integer,</span></font></b><pclass="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">bb</span><span
style="mso-tab-count:3">                               </span>integer,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">so</span><span
style="mso-tab-count:3">                               </span>integer,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="SpellE"><span
class="GramE">sh</span></span><spanstyle="mso-tab-count:3">                               
</span>integer,</span></font></b><pclass="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="SpellE"><span
class="GramE">sf</span></span><spanstyle="mso-tab-count:3">                                
</span>integer,</span></font></b><pclass="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="SpellE"><span
class="GramE">ibb</span></span><spanstyle="mso-tab-count: 
3">                               </span>integer,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="SpellE"><span
class="GramE">hbp</span></span><spanstyle="mso-tab-count: 
3">                              </span>integer,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">primary</span>
key(id),</span></font></b><pclass="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">foreign</span> key(id)
referencesstatistics(id)</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:2">                        </span><span class="GramE">on</span>
deletecascade</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold">);</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"> </span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><span
class="GramE"><b><fontface="System" size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold">create</span></font></b></span><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"> table <span class="SpellE">pitching_stats</span></span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold">(</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">id</span><span
style="mso-tab-count:3">                                </span>integer not null,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">w</span><span
style="mso-tab-count:3">                                 </span>integer,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">l</span><span
style="mso-tab-count:3">                                  </span>integer,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="SpellE"><span
class="GramE">gs</span></span><spanstyle="mso-tab-count:3">                               
</span>integer,</span></font></b><pclass="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">cg</span><span
style="mso-tab-count:3">                               </span>integer,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="SpellE"><span
class="GramE">sh</span></span><spanstyle="mso-tab-count:3">                               
</span>integer,</span></font></b><pclass="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="SpellE"><span
class="GramE">sv</span></span><spanstyle="mso-tab-count:3">                               
</span>integer,</span></font></b><pclass="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="SpellE"><span
class="GramE">ip</span></span><spanstyle="mso-tab-count:3">                                
</span>numeric(5,1),</span></font></b><pclass="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">h</span><span
style="mso-tab-count:3">                                 </span>integer,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="SpellE"><span
class="GramE">er</span></span><spanstyle="mso-tab-count:3">                                
</span>integer,</span></font></b><pclass="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">hr</span><span
style="mso-tab-count:3">                                </span>integer,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">bb</span><span
style="mso-tab-count:3">                               </span>integer,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">so</span><span
style="mso-tab-count:3">                               </span>integer,</span></font></b><p class="MsoNormal"
style="mso-layout-grid-align:none"><b><fontface="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">primary</span>
key(id),</span></font></b><pclass="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System" size="2"><span
style="font-size:10.0pt;font-family:System;mso-bidi-font-family:
System;font-weight:bold"><span style="mso-tab-count:1">            </span><span class="GramE">foreign</span> key(id)
referencesstatistics(id)</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"><span style="mso-tab-count:2">                        </span><span class="GramE">on</span>
deletecascade</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font face="System"
size="2"><spanstyle="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold">);</span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"> </span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"> </span></font></b><p class="MsoNormal" style="mso-layout-grid-align:none"><b><font
face="System"size="2"><span style="font-size:10.0pt;font-family:System;mso-bidi-font-family: 
System;font-weight:bold"> </span></font></b><p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size:10.0pt;
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Times New Roman" size="3"><span style="font-size:
12.0pt"> </span></font></div>

pgsql-sql by date:

Previous
From: "fstelpstra@yahoo.com"
Date:
Subject: Re: Can this query be optimized?
Next
From: "Jeff Sack"
Date:
Subject: Optimizing