Initial add of defaria.com
[clearscm.git] / defaria.com / blogs / Status / archives / week_2006_12_17.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: December 17, 2006 - December 23, 2006 Archives</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/week_2006_12_10.html" title="December 10, 2006 - December 16, 2006" />
16    <link rel="next" href="http://defaria.com/blogs/Status/archives/week_2006_12_24.html" title="December 24, 2006 - December 30, 2006" />
17 </head>
18 <body class="layout-one-column">
19    <div id="container">
20       <div id="container-inner" class="pkg">
21
22          <div id="banner">
23             <div id="banner-inner" class="pkg">
24                <h1 id="banner-header"><a href="http://defaria.com/blogs/Status/" accesskey="1">Status for Andrew DeFaria</a></h1>
25                <h2 id="banner-description">Searchable status reports and work log</h2>
26             </div>
27          </div>
28
29          <div id="pagebody">
30             <div id="pagebody-inner" class="pkg">
31                <div id="alpha">
32                   <div id="alpha-inner" class="pkg">
33                      
34                      <p class="content-nav">
35                         <a href="http://defaria.com/blogs/Status/archives/week_2006_12_10.html">&laquo; December 10, 2006 - December 16, 2006</a> |
36                         <a href="http://defaria.com/blogs/Status/">Main</a>
37                         | <a href="http://defaria.com/blogs/Status/archives/week_2006_12_24.html">December 24, 2006 - December 30, 2006 &raquo;</a>
38                      </p>
39                      
40                      
41                      
42
43                      <h2 class="date-header">December 19, 2006</h2>
44                      <a id="a000602"></a>
45                      <div class="entry" id="entry-602">
46                         <h3 class="entry-header">GPDB Database performance</h3>
47                         <div class="entry-content">
48                            <div class="entry-body">
49                               <ul>
50   <li>Moved convertdb and gpdb_add_vob into Clearcase</li>
51
52   <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>
53
54   <li>Discovered that Oracle is not supported on Linux here at TI. This will be a problem for GPDB</li>
55
56   <li>Still working on issues of the new GPDB design and attempting to get gpdb_add_project.pl to work with it</li>
57
58   <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>
59
60   <li>Developed a new API, gpdb_getProjectsAtSite that returns only the project names in a more efficient manner</li>
61 </ul>
62                               
63                               <h3>gpdb_getProjectsAtSite</h3>
64
65 <p>Donna may be right and we may need to enlist the help of Ajay here.</p>
66
67 <p>I coded up a gpdb_getProjectsAtSite function:</p>
68
69 <div class=code><pre>
70 sub gpdb_getProjectsAtSite ($$) {
71   my ($site_name, $resource) = @_;
72
73   resetErr ();
74  
75   unless (lc $resource eq "clearcase" or
76           lc $resource eq "designsync") {
77     setError (-1, "gpdb_getProjectsAtSite: Resource must be one of 'clearcase' or 'designsync'");
78     return ();
79   } # unless
80
81   my $siteID    = siteID $site_name;
82   my $condition    = "site_id = $siteID and $resource = 'Y'";
83
84   my @projects = @{GPDB::primitive::searchData ("projects", $condition)};
85   my @project_names;
86
87   foreach (@projects) {
88     my %project    = %{$_};
89     my $name    = projectName $project {PARENT_PROJ_ID};
90
91     next if !$name;
92
93     push @project_names, $name;
94   } # foreach
95
96   return @project_names;
97 } # gpdb_getProjectsAtSite
98 </pre></div>
99
100 <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
101 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>
102
103 <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>
104
105 <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>
106
107 <p>I do not see how I could make this any faster.</p>
108
109 <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>
110
111 <div class=code><pre>
112 <b>Dallas:</b><u>time testproj_names.pl</u>
113 real    0m7.156s
114 user    0m1.260s
115 sys     0m0.310s
116  
117 <b>Manchester:</b><u>time testproj_names.pl</u>
118 real    0m23.708s
119 user    0m0.490s
120 sys     0m0.170s
121 </pre></div>
122
123 <p>That's 24 seconds from Manchester or roughly 3.5 times as slow.</p>
124
125 <p>Switching over to selecting designsync records, there are 9 of them at Dallas. Timings for this are:</p>
126
127 <div class=code><pre>
128 <b>Dallas:</b><u>time testproj_names.pl</u>
129 real    0m1.402s
130 user    0m0.810s
131 sys     0m0.120s
132
133 <b>Manchester:</b><u>time testproj_names.pl</u>
134 real    0m3.646s
135 user    0m0.300s
136 sys     0m0.080s
137 </pre></div>
138
139 <p>Again in the order of 3 times as slow</p>
140                               
141                               <p class="entry-footer">
142                                  <span class="post-footers">Posted by  at  5:32 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000602.html">Permalink</a>
143                                  
144                                  
145                               </p>
146                            </div>
147                         </div>
148                      </div>
149                      
150                   </div>
151                </div>
152             </div>
153          </div>
154       </div>
155    </div>
156 </body>
157 </html>