Initial add of defaria.com
[clearscm.git] / defaria.com / blogs / Status / archives / 000602.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" id="sixapart-standard">
4 <head>
5    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6    <meta name="generator" content="Movable Type 5.2.3" />
7
8    <link rel="stylesheet" href="http://defaria.com/blogs/Status/styles-site.css" type="text/css" />
9    <link rel="alternate" type="application/atom+xml" title="Atom" href="http://defaria.com/blogs/Status/atom.xml" />
10    <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://defaria.com/blogs/Status/index.xml" />
11
12    <title>Status for Andrew DeFaria: GPDB Database performance</title>
13
14    <link rel="start" href="http://defaria.com/blogs/Status/" title="Home" />
15    <link rel="prev" href="http://defaria.com/blogs/Status/archives/000601.html" title="Users/Sites and Projects" />
16    <link rel="next" href="http://defaria.com/blogs/Status/archives/000603.html" title="Reworking GPDB tables, mkview" />
17
18    
19
20    
21
22    <script type="text/javascript" src="http://defaria.com/blogs/Status/mt-site.js"></script>
23 </head>
24 <body class="layout-one-column" onload="individualArchivesOnLoad(commenter_name)">
25    <div id="container">
26       <div id="container-inner" class="pkg">
27
28          <div id="banner">
29             <div id="banner-inner" class="pkg">
30                <h1 id="banner-header"><a href="http://defaria.com/blogs/Status/" accesskey="1">Status for Andrew DeFaria</a></h1>
31                <h2 id="banner-description">Searchable status reports and work log</h2>
32             </div>
33          </div>
34
35          <div id="pagebody">
36             <div id="pagebody-inner" class="pkg">
37                <div id="alpha">
38                   <div id="alpha-inner" class="pkg">
39
40                      <p class="content-nav">
41                         <a href="http://defaria.com/blogs/Status/archives/000601.html">&laquo; Users/Sites and Projects</a> |
42                         <a href="http://defaria.com/blogs/Status/">Main</a>
43                         | <a href="http://defaria.com/blogs/Status/archives/000603.html">Reworking GPDB tables, mkview &raquo;</a>
44                      </p>
45
46                      <a id="a000602"></a>
47                      <div class="entry" id="entry-602">
48                         <h3 class="entry-header">GPDB Database performance</h3>
49                         <div class="entry-content">
50                            <div class="entry-body">
51                               <ul>
52   <li>Moved convertdb and gpdb_add_vob into Clearcase</li>
53
54   <li>Attempting to standardize which Perl to use, which Oracle.pm to pickup and how to insure that other sites have the proper prerequisites for GPDB</li>
55
56   <li>Discovered that Oracle is not supported on Linux here at TI. This will be a problem for GPDB</li>
57
58   <li>Still working on issues of the new GPDB design and attempting to get gpdb_add_project.pl to work with it</li>
59
60   <li>Got definition of performance problem that Donna is experiencing. She is attempting to populate a pull down with just the project names for a site. Doing so causes lots of transfer of data as the current GPDB API gpdb_getProject effectively transfers all kinds of project information where Donna needs only the project names.</li>
61
62   <li>Developed a new API, gpdb_getProjectsAtSite that returns only the project names in a more efficient manner</li>
63 </ul>
64                            </div>
65                            <div id="more" class="entry-more">
66                               <h3>gpdb_getProjectsAtSite</h3>
67
68 <p>Donna may be right and we may need to enlist the help of Ajay here.</p>
69
70 <p>I coded up a gpdb_getProjectsAtSite function:</p>
71
72 <div class=code><pre>
73 sub gpdb_getProjectsAtSite ($$) {
74   my ($site_name, $resource) = @_;
75
76   resetErr ();
77  
78   unless (lc $resource eq "clearcase" or
79           lc $resource eq "designsync") {
80     setError (-1, "gpdb_getProjectsAtSite: Resource must be one of 'clearcase' or 'designsync'");
81     return ();
82   } # unless
83
84   my $siteID    = siteID $site_name;
85   my $condition    = "site_id = $siteID and $resource = 'Y'";
86
87   my @projects = @{GPDB::primitive::searchData ("projects", $condition)};
88   my @project_names;
89
90   foreach (@projects) {
91     my %project    = %{$_};
92     my $name    = projectName $project {PARENT_PROJ_ID};
93
94     next if !$name;
95
96     push @project_names, $name;
97   } # foreach
98
99   return @project_names;
100 } # gpdb_getProjectsAtSite
101 </pre></div>
102
103 <p>Basically you call it with a site name and a resource (being clearcase or designsync). It does some housekeeping (resetting the error variables and checking that resource is one of clearcase or designsync). Next it translates the site name to an ID. We need an ID
104 and we shouldn't burden the users with having to supply that. The siteID function is a new internal function for gpdb.pm because I often find the need to translate a site name to an ID. Next we compose a condition which is the part after "where" that says find things that have "site_id = $siteID and $resource = 'Y'". Remember resource is either "clearcase" or "designsync" and we wish to find project records where the site matches and the resource is toggled on (i.e. = 'Y').</p>
105
106 <p>There's a new primitive, searchData because getData only finds single records by "ID" only and findData will return multiple records based on a fieldname = value specific condition. Here we want two different fieldname/value pairs and an "and" condition. Therefore the searchData primitive takes two parameters, the table name and the condition, and composes a "select * from $tableName where $condition" and returns an array of hashes like findData does.</p>
107
108 <p>At this point we have an array of projects whose site IDs match our passed in Site Name and whose $resource is toggled on as 'Y'. But we want to return project names to be nice for the user and that's what the foreach loop does. Note it calls another new internal routine called projectName which returns the project's name for the product ID (the parent project ID that is). Note also that projectName will return undef if the project is retired. That's what the "next if !$name" statement is for. All non-retired project names therefore are pushed onto @project_names which are returned from the subroutine.</p>
109
110 <p>I do not see how I could make this any faster.</p>
111
112 <p>Well how did it perform? Selecting on Dallas and Clearcase projects (because gpdb_add_project.pl that does DesignSync additions is still not working well) there are 194 Clearcase projects at the Dallas site. Running a small test script here and at Manchester yields:</p>
113
114 <div class=code><pre>
115 <b>Dallas:</b><u>time testproj_names.pl</u>
116 real    0m7.156s
117 user    0m1.260s
118 sys     0m0.310s
119  
120 <b>Manchester:</b><u>time testproj_names.pl</u>
121 real    0m23.708s
122 user    0m0.490s
123 sys     0m0.170s
124 </pre></div>
125
126 <p>That's 24 seconds from Manchester or roughly 3.5 times as slow.</p>
127
128 <p>Switching over to selecting designsync records, there are 9 of them at Dallas. Timings for this are:</p>
129
130 <div class=code><pre>
131 <b>Dallas:</b><u>time testproj_names.pl</u>
132 real    0m1.402s
133 user    0m0.810s
134 sys     0m0.120s
135
136 <b>Manchester:</b><u>time testproj_names.pl</u>
137 real    0m3.646s
138 user    0m0.300s
139 sys     0m0.080s
140 </pre></div>
141
142 <p>Again in the order of 3 times as slow</p>
143                            </div>
144                         </div>
145                         <p class="entry-footer">
146                            <span class="post-footers">Posted by  on December 19, 2006  5:32 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000602.html">Permalink</a>
147                         </p>
148                      </div>
149
150                      
151
152                      
153                   </div>
154                </div>
155             </div>
156          </div>
157       </div>
158    </div>
159 </body>
160 </html>