<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>Esoteric Curio - PostgreSQL</title>
    <link>http://lethargy.org/~jesus/</link>
    <description>Theo's Contributions to Technological Surreality</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.4.1 - http://www.s9y.org/</generator>
    <pubDate>Thu, 18 Mar 2010 18:07:13 GMT</pubDate>

    <image>
        <url>http://lethargy.org/~jesus/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: Esoteric Curio - PostgreSQL - Theo's Contributions to Technological Surreality</title>
        <link>http://lethargy.org/~jesus/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Managing risk by deploying incessantly</title>
    <link>http://lethargy.org/~jesus/writes/managing-risk-by-deploying-incessantly</link>
            <category>Damaged Bits</category>
            <category>OpenSolaris</category>
            <category>PostgreSQL</category>
    
    <comments>http://lethargy.org/~jesus/writes/managing-risk-by-deploying-incessantly#comments</comments>
    <wfw:comment>http://lethargy.org/~jesus/wfwcomment.php?cid=175</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://lethargy.org/~jesus/rss.php?version=2.0&amp;type=comments&amp;cid=175</wfw:commentRss>
    

    <author>nospam@example.com (Theo Schlossnagle)</author>
    <content:encoded>
    &lt;p&gt;I recently took the time to write down &lt;a href=&quot;http://omniti.com/seeds/online-application-deployment-reducing-risk&quot;&gt;my thoughts on why successfully managing code deployments in an online architecture is so radically different from release management in a traditional software engineering endeavor&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;
Perhaps most challenging is the pace at which competition moves. In the online world, I can have an idea this morning, an implementation this afternoon and every client of my service that shows up tomorrow will see it. In fact, things can and do happen much faster than that. You might think that rapid concept-to-availability push is reckless. You might be right. But, your competition is doing it.
&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href=&quot;http://omniti.com/seeds/online-application-deployment-reducing-risk&quot;&gt;Read more&lt;/a&gt;.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Thu, 18 Mar 2010 14:07:13 -0400</pubDate>
    <guid isPermaLink="false">http://lethargy.org/~jesus/writes/175</guid>
    
</item>
<item>
    <title>Squeezing precise numbers into fixed width types... or faking it</title>
    <link>http://lethargy.org/~jesus/writes/squeezing-precise-numbers-into-fixed-width-types-or-faking-it</link>
            <category>OpenSolaris</category>
            <category>PostgreSQL</category>
    
    <comments>http://lethargy.org/~jesus/writes/squeezing-precise-numbers-into-fixed-width-types-or-faking-it#comments</comments>
    <wfw:comment>http://lethargy.org/~jesus/wfwcomment.php?cid=174</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://lethargy.org/~jesus/rss.php?version=2.0&amp;type=comments&amp;cid=174</wfw:commentRss>
    

    <author>nospam@example.com (Theo Schlossnagle)</author>
    <content:encoded>
    &lt;p&gt;I have this app where we store numbers.  Don&#039;t we all?  Unfortunately, this app stores numbers without context.  So, I don&#039;t know whether the number will be an integer or represent numbers throughout the real number space.  Compounding this situation, I stand to gain particular advantage if I can store all these numbers in a fixed width datatype (each number consume the same number of bits of storage space).  On current computer systems, there are two native types to each do some of what we want: the 64bit &lt;a href=&quot;http://en.wikipedia.org/wiki/IEEE_754-2008&quot;&gt;IEEE floating point&lt;/a&gt; type &quot;double&quot; and the 64bit integer types &quot;signed/unisnged long long&quot;.  However, I don&#039;t know which datatype to use before I actually see the number for the first time.&lt;/p&gt;

&lt;p&gt;Let&#039;s take temperature as an example.  In some accepted unit like C, F or K a possible value would be something like 37.23 or 49.05 which is a non-integer value where it would seem to make sense to use a float or a double.  Round trip time in seconds is a great example of what one would think of as a perfect use for a IEEE floating point number as a float or a double.  In that format, the most significant digits are more accurate, so if you are measuring the latency between two networked system (microseconds) or you are measuring the time to run an enormous data mining operation (days) you will get something accurate.  Why is a type that looses accuracy okay here?  If your operation takes months or years to complete an operation, you don&#039;t likely care if the operation took 2 years and 37 microseconds or 2 years and 12 microseconds.  It may seem that a double would, generally speaking, be pretty good for just about anything.  Not so.&lt;/p&gt;

&lt;p&gt;In the real world, we frequently measure the number of octets (bytes) passed through switching equipment.  These numbers are typically represented in a counter that ranges in integral value between 0 and 2&lt;sup&gt;64&lt;/sup&gt;-1.  Now, if we store the number as a double, as we approach the upper end, the double starts to loose accuracy.  Here&#039;s a quick sample so you can see it.  I&#039;ll take X and X+100 as doubles and then subtract them to see the difference.  As X gets very very large, 100 is less significant (the one-hundreds place), so we start to loose accuracy.  I save you some reading by starting at 2&lt;sup&gt;48&lt;/sup&gt; as that&#039;s where the interesting things start.&lt;/p&gt;

&lt;pre&gt;
#include &lt;stdio.h&gt;
#include &lt;stdint.h&gt;
#include &lt;math.h&gt;

int main() {
  int i;
  for(i=48;i&lt;63;i++) {
    uint64_t i1 = 1;
    double d1;
    i1 &lt;&lt;= i;
    d1 = (double)(i1 + 100);
    printf(&quot;%g - %llu = 100, saw %llu (%g%%)\n&quot;,
           d1, i1, (uint64_t)d1 - i1,
           fabs((double)((uint64_t)d1 - i1)-100.0));
  }
}
&lt;/pre&gt;

&lt;p&gt;Producing the output:&lt;/p&gt;

&lt;pre&gt;
2.81475e+14 - 281474976710656 = 100, saw 100 (0%)
5.6295e+14 - 562949953421312 = 100, saw 100 (0%)
1.1259e+15 - 1125899906842624 = 100, saw 100 (0%)
2.2518e+15 - 2251799813685248 = 100, saw 100 (0%)
4.5036e+15 - 4503599627370496 = 100, saw 100 (0%)
9.0072e+15 - 9007199254740992 = 100, saw 100 (0%)
1.80144e+16 - 18014398509481984 = 100, saw 100 (0%)
3.60288e+16 - 36028797018963968 = 100, saw 96 (4%)
7.20576e+16 - 72057594037927936 = 100, saw 96 (4%)
1.44115e+17 - 144115188075855872 = 100, saw 96 (4%)
2.8823e+17 - 288230376151711744 = 100, saw 128 (28%)
5.76461e+17 - 576460752303423488 = 100, saw 128 (28%)
1.15292e+18 - 1152921504606846976 = 100, saw 0 (100%)
2.30584e+18 - 2305843009213693952 = 100, saw 0 (100%)
4.61169e+18 - 4611686018427387904 = 100, saw 0 (100%)
&lt;/pre&gt;

&lt;p&gt;You might ask, why the one-hundreds place is important in numbers that are this large.  The answer is very simple.  This measures octets through a switch, think of milliliters of water from a faucet.  After you&#039;ve used the faucet a long time, that number is staggering.  However, if I want to know liters/second over the last 5 seconds it is very likely that the two samples I take (now and five seconds from now) will be both enormous and relatively close.  And while the accuracy of difference matters, it is too insignificant to be represented in the IEEE floating point format.  The interesting thing is, the source never reports anything but integral values, so if we were simply using an integral datatype we would have exactness.&lt;/p&gt;

&lt;p&gt;So, what do you do when you don&#039;t know?  Arbitrary precision math, or in SQL: numeric.  Numerics are great because you always get the correct answer.  Numerics are bad because computers are not very good at doing math outside of the IEEE floating point and integral spaces; in other words, it&#039;s painfully slow.  Perhaps worse than being slow, the numeric datatype is a variable width type, which in this case means I&#039;ve lost the battle.&lt;/p&gt;

&lt;p&gt;Now back to my app: the inputs are either floating point numbers or integral numbers, but the only way we can tell is if they contain a decimal point when expressed in non-scientific notation; or, do they have any non-zero values in places to the right of the one&#039;s place?  What we want to do is give accurate integral storage to apps that are courteous enough to provide integral numbers in the range of -2&lt;sup&gt;63&lt;/sup&gt; to 2&lt;sup&gt;64&lt;/sup&gt;-1 and use a double otherwise.  This allows us to use 64bits of fixed space to store the value (though we need some extra bits to note that the 64bits represents a double vs. a signed integer vs. an unsigned integer).  Once we&#039;ve tackled this, we can accept numeric values from SQL stored them in fixed size (with expected loss of insignificant places for floating point and expected accuracy for integral values) and return them back as numerics.&lt;/p&gt;

&lt;p&gt;My little project fronts against &lt;a href=&quot;http://postgresql.org&quot;&gt;PostgreSQL&lt;/a&gt;, so I had to convert integers and doubles into numerics.  Much to my surprise, the internal method of converting this is to convert from type1 to a string and then from a string to type2.  This is a very inefficient process.  It turns out that &lt;a href=&quot;https://labs.omniti.com/pgsoltools/trunk/contrib/scratch/pg_type_to_numeric.c&quot;&gt;direct double to numeric conversion&lt;/a&gt; (as expected) is much faster.  In our case it shaves off approximately 50% of the CPU cycles.&lt;/p&gt;

&lt;p&gt;As a disclaimer, this is a very special purposed storage type and neither replaces the double, integer or numeric type.  It is, instead, a hybrid type with special properties that are attuned to the problem at hand.  Before you go implementing something similar, make sure you know what you are doing.  Our goals were to retain accuracy for integral types, achieve a fixed-width storage format and still allow representation of numbers both large and arbitrarily smaller than 1.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Fri, 05 Mar 2010 09:13:56 -0500</pubDate>
    <guid isPermaLink="false">http://lethargy.org/~jesus/writes/174</guid>
    
</item>
<item>
    <title>Sexified fonts for the web.</title>
    <link>http://lethargy.org/~jesus/writes/sexified-fonts-for-the-web</link>
            <category>Damaged Bits</category>
            <category>OpenSolaris</category>
            <category>PostgreSQL</category>
            <category>Rambling</category>
            <category>Writing</category>
    
    <comments>http://lethargy.org/~jesus/writes/sexified-fonts-for-the-web#comments</comments>
    <wfw:comment>http://lethargy.org/~jesus/wfwcomment.php?cid=171</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://lethargy.org/~jesus/rss.php?version=2.0&amp;type=comments&amp;cid=171</wfw:commentRss>
    

    <author>nospam@example.com (Theo Schlossnagle)</author>
    <content:encoded>
    &lt;p&gt;&lt;a href=&quot;http://omniti.com/&quot;&gt;OmniTI&lt;/a&gt; has been working with &lt;a href=&quot;http://clearleft.com/&quot;&gt;Clearleft&lt;/a&gt; for a while now on &lt;a href=&quot;http://fontdeck.com/&quot;&gt;Fontdeck&lt;/a&gt;.  The super &lt;a href=&quot;http://omniti.com/is/greg-chiasson&quot;&gt;Greg Chiasson&lt;/a&gt; has been pushing our beta live and I&#039;ve been provisioning machines and setting up infrastructure just so you can read this web page in a nice sexy font... Nice... Sexy.&lt;/p&gt;

&lt;p&gt;And yes, of course, fontdeck is powered by our friends: Apache, PostgreSQL, OpenSolaris, a bit of Linux here and there, a sprinkling of both asymmetric and symmetric cryptography and an ancient dialect of computer-speak called Perl.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Mon, 11 Jan 2010 15:08:05 -0500</pubDate>
    <guid isPermaLink="false">http://lethargy.org/~jesus/writes/171</guid>
    
</item>
<item>
    <title>Asynchronous PostgreSQL Candy</title>
    <link>http://lethargy.org/~jesus/writes/asynchronous-postgresql-candy</link>
            <category>BWPUG</category>
            <category>Damaged Bits</category>
            <category>OpenSolaris</category>
            <category>PostgreSQL</category>
    
    <comments>http://lethargy.org/~jesus/writes/asynchronous-postgresql-candy#comments</comments>
    <wfw:comment>http://lethargy.org/~jesus/wfwcomment.php?cid=170</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://lethargy.org/~jesus/rss.php?version=2.0&amp;type=comments&amp;cid=170</wfw:commentRss>
    

    <author>nospam@example.com (Theo Schlossnagle)</author>
    <content:encoded>
    &lt;p&gt;I&#039;ve put the first (intended) use of the &lt;a href=&quot;http://labs.omniti.com/trac/pgsoltools/browser/trunk/contrib/pg_amqp&quot;&gt;pg_amqp&lt;/a&gt; setup to the test.  So far I&#039;m very pleased.  While none of the code for the usage is open source the real &quot;magic sauce&quot; is open and has had a few bug fixes and bits of robustness added since I last posted. I can, however, describe the use and let your imagination run while.&lt;/p&gt;

&lt;p&gt;The parts: &lt;a href=&quot;http://www.postgresql.org/&quot;&gt;PostgreSQL&lt;/a&gt;, &lt;a href=&quot;http://www.rabbitmq.com/&quot;&gt;RabbitMQ&lt;/a&gt;, and a bit of Java around &lt;a href=&quot;http://lucene.apache.org&quot;&gt;Lucene&lt;/a&gt;.  Our java program actually uses &lt;a href=&quot;http://www.mortbay.org/jetty/&quot;&gt;jetty&lt;/a&gt; to expose a tiny servlet that accepts search queries and returns json results making AJAX-style searches easy and fast.&lt;/p&gt;

&lt;p&gt;The obvious question we all face in these sort of configurations is &quot;how do keep our search indexes up-to-date?&quot;  Usually, we relax constraints (wisely so) and determine exactly &quot;how up-to-date does out index needs to be.&quot;  If you can answer this question with a number sufficiently far from zero, you&#039;ve won.  In our situation, the user experience must be able to search and find the updated items in database via search immediately after insert or update (within a 100ms or so).&lt;/p&gt;

&lt;p&gt;Enter message queueing.  The first thing we do is make our Java process connect to RabbitMQ, bind a queue and consume.  The messages it consumes from the queue have instructions on the precise element that has changed which then causes an query against the database retrieving all the new data to be reindexed (in our case, it is much more than can be easily witnessed from a trigger on update) and updates the Lucene indexes.&lt;/p&gt;

&lt;p&gt;The second updated we made is to PostgreSQL by installing pg_amqp.  On the tables whose changes should induce reindexing, we add a (or augment the existing) trigger to call: amqp.publish(&#039;amq.direct&#039;, &#039;searchstuff&#039;, E&#039;reindex\t&#039; || NEW.rowid).  Assuming we have a column called rowid, this will queue a message that looks like &quot;reindex&amp;lt;tab&amp;gt;328432&quot;&lt;/p&gt;

&lt;p&gt;The neat part is that if the update is rolled back in the database, the message is never sent.  Otherwise, we see the message from the our indexing and search app and viola.&lt;/p&gt;

&lt;p&gt;I think this technique is really useful for people that are currently leveraging Lucene-based systems to provide powerful search functionality yet keep their data safe and secure in PostgreSQL.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Sun, 27 Dec 2009 13:49:32 -0500</pubDate>
    <guid isPermaLink="false">http://lethargy.org/~jesus/writes/170</guid>
    
</item>
<item>
    <title>AMQP for PostgreSQL</title>
    <link>http://lethargy.org/~jesus/writes/amqp-for-postgresql</link>
            <category>Damaged Bits</category>
            <category>OpenSolaris</category>
            <category>PostgreSQL</category>
    
    <comments>http://lethargy.org/~jesus/writes/amqp-for-postgresql#comments</comments>
    <wfw:comment>http://lethargy.org/~jesus/wfwcomment.php?cid=169</wfw:comment>

    <slash:comments>3</slash:comments>
    <wfw:commentRss>http://lethargy.org/~jesus/rss.php?version=2.0&amp;type=comments&amp;cid=169</wfw:commentRss>
    

    <author>nospam@example.com (Theo Schlossnagle)</author>
    <content:encoded>
    &lt;p&gt;So, it turns out that being stranded in an airport can lead to some productive output after all.&lt;/p&gt;

&lt;p&gt;I&#039;ve hacked together an AMQP extension for PostgreSQL.  If you don&#039;t know what AMQP or PostgreSQL are, stop reading.&lt;/p&gt;

&lt;p&gt;One thing I&#039;ve needed to do for a while is be able to submit a message to a message queue from within a PostgreSQL transaction.  However, obviously (because we run a real database here), if the transaction aborts I&#039;d rather not have those messages sent.  Enter pg_amqp.&lt;/p&gt;

&lt;p&gt;pg_amqp allows:&lt;/p&gt;
&lt;ul&gt;
 &lt;li&gt;Multiple connections to different AMQP brokers (configured in the amqp.broker table).&lt;/li&gt;
 &lt;li&gt;Allows for the declaration of an exchange.&lt;/li&gt;
 &lt;li&gt;Tries to be smart about bring up a connection to a broker on demand and leaving it connected to accelerate the next publication request.&lt;/li&gt;
 &lt;li&gt;Allows AMQP publishing from within SQL that is transactionally aware (only publishes on commit).&lt;/li&gt;
 &lt;li&gt;Allows AMQP publishing from within SQL that is autonomous (happens outside the current transaction).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is completely alpha.  I&#039;ve tested it quite a bit by hand, but put no load on it whatsoever.  Monday of next week, I&#039;m going to beat the ever-living @#$% out of it on one of our systems that desperately needs on-commit AMQP notifications.&lt;/p&gt;

&lt;p&gt;I&#039;d love some more eyes on this.  It has some flaws, specifically related to processing asynch events from within a PosgreSQL backend (which has no concept of asynchronous even notification).  As such, if you do stupid stuff, stupid things happen.  The easiest solution is to add a thread to each postgres backend to process the backqueue of events from AMQP; however that so blatantly violates postgres&#039; process model and design that I&#039;ve no intention to do that.  With all the issues aside &amp;#8212; it works pretty well for me.&lt;/p&gt;

&lt;p&gt;I didn&#039;t add queue declaration or the ability to consume from queues.  That was intentional because PostgreSQL can&#039;t run SQL outside of a transaction block making a while(1) { consume, do, commit } impossible from within SQL itself.  Without the ability to do that it seems really useless (and pretty dangerous) to allow someone to do a blocking AMQP frame receive from within SQL.  If you think it would be useful for you, let me know &amp;#8212; it would be a trivial addition.&lt;/p&gt;

&lt;p&gt;Oh yeah: &lt;a href=&quot;https://labs.omniti.com/pgsoltools/trunk/contrib/pg_amqp&quot;&gt;pg_amqp&lt;/a&gt;&lt;/p&gt;
 
    </content:encoded>

    <pubDate>Sat, 19 Dec 2009 18:00:27 -0500</pubDate>
    <guid isPermaLink="false">http://lethargy.org/~jesus/writes/169</guid>
    
</item>
<item>
    <title>OmniTI seeks data management experts; a new type of DBA.</title>
    <link>http://lethargy.org/~jesus/writes/omniti-seeks-data-management-experts;-a-new-type-of-dba</link>
            <category>OpenSolaris</category>
            <category>PostgreSQL</category>
    
    <comments>http://lethargy.org/~jesus/writes/omniti-seeks-data-management-experts;-a-new-type-of-dba#comments</comments>
    <wfw:comment>http://lethargy.org/~jesus/wfwcomment.php?cid=168</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://lethargy.org/~jesus/rss.php?version=2.0&amp;type=comments&amp;cid=168</wfw:commentRss>
    

    <author>nospam@example.com (Theo Schlossnagle)</author>
    <content:encoded>
    &lt;p&gt;What&#039;s a DBA?  Database administrator? Database architect?  Whatever it is, we need one (or two or three) at &lt;a href=&quot;http://omniti.com/&quot;&gt;OmniTI&lt;/a&gt;.  The problem is that the Jurassic variant of the DBA simply can&#039;t cut it in today&#039;s world of the web giants (OmniTI services the web giants).  What is it about the modern use of database in the web world that make traditionals DBAs so inadequate?  It&#039;s actually a variety of things. If you think tackling them is a challenge you&#039;re cut out for, send me your resume!&lt;/p&gt;

&lt;h3&gt;Scale&lt;/h3&gt;

&lt;p&gt;One might say &quot;Scale? Scale? Are you kidding me? Traditional database problems come in various flavors of gigantic.&quot;  This is true, but the unique dynamics of the web mean that not only is the data flowing in at uncontrollable rates, but tomorrow there is always a new data source with a new representation.  Due to the scale of external systems and your own it makes for an interesting sandbox in which we play.  A multi-terabyte database is quite common just about anywhere these days; however, ten of them running four different data management platforms is rather common place within large web infrastructures.&lt;/p&gt;

&lt;h3&gt;Continuity&lt;/h3&gt;

&lt;p&gt;This is the real game changer. This is the mental paradigm shift that classical DBAs struggle with most.  Try this on for size: &quot;no maintenance windows.&quot;  Okay, admittedly that is a stretch, but only a small stretch.  How about 5 minutes of database downtime allowed every 4 weeks or, worse, every 52 weeks.&lt;/p&gt;

&lt;p&gt;Coupled with this is daily (or more frequent) code rollout often times requiring database schema change, new triggers, and different replication dynamics.&lt;/p&gt;

&lt;p&gt;The amount of seemingly ass-backwards engineering required to accomplish this feat is usually described as either: &quot;excruciating pit of hell&quot; or &quot;fascinating enigma.&quot; (I think of it as both)  What I do know is that I have seen some of the most profound data engineering creativity emerge from this insipid constraint.&lt;/p&gt;

&lt;h3&gt;Innovation&lt;/h3&gt;

&lt;p&gt;While noSQL is a fanatical movement that needs to be kept in check, the problems it addresses are real and [some of] the solutions promoted are good.  Understanding when data better fits in a key-value store is something that the classically trained DBA struggles with.  It&#039;s all about data management: Dynomite, CouchDB, Cassandra, Oracle, &lt;a href=&quot;http://omniti.com/does/postgresql&quot;&gt;PostgreSQL&lt;/a&gt;, MySQL… they all have a sweet spot &amp;emdash; know it.&lt;/p&gt;

&lt;h3&gt;Scope&lt;/h3&gt;

&lt;p&gt;The other interesting dynamic has less to do with data management and has more to due with the pace and culture of web companies.  In traditional companies, roles are more disjointed; DBAs have a set of responsibilities that software engineers and system administrators do not have and those two groups have a set of responsibilities with which DBAs need not concern themselves. This &quot;silo effect&quot; spells absolute disaster for web companies.&lt;/p&gt;

&lt;p&gt;The pace on the web is simply too fast (I often think it is a bit reckless, but that&#039;s another rant) to keep all the parts separate.  An insufficient amount of time exists to define how one layer of an architecture will communicate with another layer.  And while the layers meet at reasonable places most of the time, there are other places where the lines are blurred.  These are the points in the architecture that stand to have the highest efficiency, but also are the hardest to troubleshoot; they require an organization of engineers that have no boundaries.  In the case of a DBA… one that wants to look at the ORM code that builds the insanely awful SQL queries that beat the stuffing out of their database every second; one that is actually aware of the storage configuration and layer-2 fabric that sits behind the magical &quot;remembering device&quot; that the database commits things to all day long.&lt;/p&gt;

&lt;h2&gt;Beat you with a stick?&lt;/h2&gt;

&lt;p&gt;Around here, &lt;a href=&quot;http://omniti.com/is/robert-treat&quot;&gt;Robert Treat&lt;/a&gt; runs the show.  The stick wielding and beatings are left to him (he a father of three, so I&#039;m sure he&#039;s more than capable).&lt;/p&gt;

&lt;p&gt;I guess the question is… are you up for the challenge?  Are you a DBA who thinks their job is about more than just ACID?  Are you a developer or an SA that has decided to make a shift and tackle the data management layer with a unique perspective?  Are you interested in mind bending problems that arrive on your plate a bit too quick for anyone&#039;s comfort level?  I hope so, because &lt;a href=&quot;http://omniti.com/is/hiring/database-administrator&quot;&gt;we need people like that&lt;/a&gt;!&lt;/p&gt; 
    </content:encoded>

    <pubDate>Thu, 17 Dec 2009 11:49:25 -0500</pubDate>
    <guid isPermaLink="false">http://lethargy.org/~jesus/writes/168</guid>
    
</item>
<item>
    <title>Itch scratched - right between the rabbit's ears.</title>
    <link>http://lethargy.org/~jesus/writes/itch-scratched-right-between-the-rabbits-ears</link>
            <category>OpenSolaris</category>
            <category>PostgreSQL</category>
    
    <comments>http://lethargy.org/~jesus/writes/itch-scratched-right-between-the-rabbits-ears#comments</comments>
    <wfw:comment>http://lethargy.org/~jesus/wfwcomment.php?cid=166</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://lethargy.org/~jesus/rss.php?version=2.0&amp;type=comments&amp;cid=166</wfw:commentRss>
    

    <author>nospam@example.com (Theo Schlossnagle)</author>
    <content:encoded>
    &lt;p&gt;&lt;a href=&quot;http://search.cpan.org/~jesus/Net-RabbitMQ-0.0.1/RabbitMQ.pm&quot;&gt;Net::RabbitMQ&lt;/a&gt;, get it while it&#039;s hot.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Fri, 13 Nov 2009 17:18:32 -0500</pubDate>
    <guid isPermaLink="false">http://lethargy.org/~jesus/writes/166</guid>
    
</item>
<item>
    <title>Extending and Embedding</title>
    <link>http://lethargy.org/~jesus/writes/extending-and-embedding</link>
            <category>Damaged Bits</category>
            <category>OpenSolaris</category>
            <category>PostgreSQL</category>
    
    <comments>http://lethargy.org/~jesus/writes/extending-and-embedding#comments</comments>
    <wfw:comment>http://lethargy.org/~jesus/wfwcomment.php?cid=165</wfw:comment>

    <slash:comments>10</slash:comments>
    <wfw:commentRss>http://lethargy.org/~jesus/rss.php?version=2.0&amp;type=comments&amp;cid=165</wfw:commentRss>
    

    <author>nospam@example.com (Theo Schlossnagle)</author>
    <content:encoded>
    &lt;p&gt;If you&amp;#8217;re like me, you&amp;#8217;ve read a handful of really useful articles about extending and embedding things like perl, Python, Java, lisp, scheme or lua.  The slant there is a technical one: &amp;#8220;So you need Java, here&amp;#8217;s how to embed it.&amp;#8221;  I&amp;#8217;ve embedded Python once, perl and Java countless times and, most recently, lua.  Throughout this I realized that I don&amp;#8217;t need the languages as much as I need a convenient extension out of C.  In other words, if your foundation app is feature-rich, embedding isn&#039;t as much about adding the features of a specific language as it is about exposing the features of your system.&lt;/p&gt;

&lt;p&gt;Given this context, there is a lack of articles about how to choose the appropriate embedding technology for a given project.  Each language has its own advantages and people religiously argue about them seemingly to no end.  Things get interesting when you look to embedding languages, as their internal implementation decisions start to influence what is and isn&#039;t possible.  I&amp;#8217;ll take you on a brief whirlwind tour of my personal experience embedding.&lt;/p&gt;

&lt;h3&gt;Perl&lt;/h3&gt;

&lt;p&gt;Many of you know I program in Perl quite often.  Many people hate Perl and believe it to be an abomination.  I love Perl for its flexibility, expressiveness and its terseness &amp;#8212; aligning it with myself.  However, the perl (5.10 and earlier) interpreter is a horrid, catastrophic example of how not to write a virtual machine for an interpreted language; spaghetti does not begin to describe that mess that is perl internals.  The API is insufficiently documented, the internal data representations are indecently exposed and the the way thread support was backed into the code (like a garbage truck through a toy shop) make it more than a challenge to embed.  Now, I&amp;#8217;ve been writing XS code for years (the C-like language for extending perl itself) and I know and love the language itself, but I&amp;#8217;d argue that it is rarely a good idea to embed perl in any application.&lt;/p&gt;

&lt;p&gt;You may have noted that I claimed to have embedded perl several times in applications.  Some of those turned out to be a good idea.  Both (yes only two) of those times, the reason it ended up being a good idea was that to make my application more useful I needed the wealth of CPAN (the comprehensive Perl archive network that contains a wealth of easy-to-use Perl wrappers around common needs).  While in the end I won, embedding perl was an awful experience and I wouldn&#039;t recommend it to anyone.  My specific problems came down to debugging memory usage as it transcends from C into Perl heap and the painful problem that is threading within perl.  Each time, integrating into perl&amp;#8217;s threading system proved a waste of time and I ended up starting an interpreter for each thread (or had a resource pool of interpreters from which each thread would reserve).  So many useful CPAN modules aren&amp;#8217;t thread-safe and were never developed with a mindset that they would be loaded into a perl that might be embedded in another system.&lt;/p&gt;

&lt;p&gt;While I love the language, I hate the implementation.&lt;/p&gt;

&lt;h3&gt;Python&lt;/h3&gt;

&lt;p&gt;While I like Python as a language, I personally find that if my job doesn&amp;#8217;t fit in perl and that Python would be a better choice, I usually think a bit harder and realize that C would be even better.  I realize this isn&amp;#8217;t the same mental leap made by most people, but I love C.  C is my favorite language.  In fact, I wouldn&amp;#8217;t be writing this article if I didn&amp;#8217;t write so many applications in C that can benefit from an embedded interpreter to ease configuration and processing tasks.&lt;/p&gt;

&lt;p&gt;In fact, I would argue that Python is a great language to embed because the of the interpreter.  It&#039;s implementation is cleaner than perl&amp;#8217;s &amp;#8212; as I&amp;#8217;ve mentioned the bar could not be set much lower.  The fact is that embedding Python in a complicated multi-threaded and/or even driven application really shows the inadequacies of its embedding design.  That combined with the fact that I&amp;#8217;d rather be coding directly in C means: &quot;I wouldn&amp;#8217;t embed that again.&quot;&lt;/p&gt;

&lt;p&gt;Now, all the applications in which I typically embed interpreters or virtual machines are complicated.  If your application is single-threaded and doesn&amp;#8217;t do extensive co-routines (e.g. closure-oriented programming or event driven systems) then Python could really be an ideal embedding language.&lt;/p&gt;

&lt;h3&gt;Java&lt;/h3&gt;

&lt;p&gt;Java is a complicated discussion.  I have a lot of mixed feelings about Java.  No language should have functions in its core distribution deprecated at the rate that Java boasts &amp;#8212; it&amp;#8217;s dysfunctional.  Java as a language itself is quite nice.  It is powerful, fast, and expressive.  It has some annoyances like its verboseness and sprawling code bases.  It has one true, deep negative: Java programmers.  Now, not all Java programmers are bad, but I&#039;ve seen far too much Java code produced by programmers far and wide that is of a quality that is flat-out unacceptably low.&lt;/p&gt;

&lt;p&gt;When you&amp;#8217;re embedding a language, some of those negatives don&amp;#8217;t matter so much.  We can instead concentrate on ease of embedding.  Java has to be, hands-down, the easiest system to embed.  The API is crystal clear and absolutely complete.  It is all held in a single, small header file called jni.h.  Every time I&amp;#8217;ve embedded Java is has been simple and painless.  JNI team, pat yourself on the back &amp;#8212; I&amp;#8217;ll happily buy a round of beers if we ever run into each other.&lt;/p&gt;

&lt;p&gt;On top of the ease of embedding, the native support for mapping application (C) threads into JVM threads is concise and demonstrates pre-meditated good engineering.&lt;/p&gt;

&lt;p&gt;One reason I don&amp;#8217;t like Java for this is that it isn&amp;#8217;t really &amp;#8220;interpreted.&amp;#8221;  I have to compile (or auto-compile) my code to get it to run in my app.  Now, perhaps I could use Java to pull in something like Jython or JRuby to make a rather obtuse, but convenient, system.  Success via indirection has never been high on my list &amp;#8212; if I ever try it, I&amp;#8217;ll be sure to let you know how it went.&lt;/p&gt;

&lt;h3&gt;Tcl, lisp, ruby, PHP&lt;/h3&gt;

&lt;p&gt;Too old, too arcane, AYFKM, leave it on the web guys, respectively.&lt;/p&gt;

&lt;p&gt;Okay, in all fairness, I didn&amp;#8217;t give Tcl its due.  It&amp;#8217;s likely the most widely embedded language.  I just don&amp;#8217;t like Tcl and it shows.&lt;/p&gt;

&lt;h3&gt;Javascript&lt;/h3&gt;

&lt;p&gt;Javascript deserves its own section for arguments against embedding a language.  If you have a single-threaded program that is not event driven, Javascript is a brilliant choice.  I don&amp;#8217;t remember the last time I wrote an application that was both that simple and was in need of an embedded language.  So, the fact that Javascript has no support for threading makes it utterly painful and obtuse to embed in most systems.  This saddens me.  Of all the languages I program in, Javascript is likely my favorite.  I know this must be on the merits of the syntax and expressiveness of the language because I loathe DOM and anything that touches it.  Oh! how I wish Javascript embraced threading.  Oh! how I wish Javascript had the embeddability of Lua.&lt;/p&gt;

&lt;h3&gt;Lua&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://www.lua.org/&quot;&gt;Lua&lt;/a&gt; is my new love.  It is the reason I decided to write this article.  I actually don&amp;#8217;t like the lua language.  I don&amp;#8217;t particularly like the internal implementation (garbage collected instead of ref counted).  It doesn&amp;#8217;t have particularly useful extensions to add feature value to your system.  So, what is it about lua?&lt;/p&gt;

&lt;p&gt;I&amp;#8127;ve been working a lot on a system called &lt;a href=&quot;https://labs.omniti.com/trac/reconnoiter&quot;&gt;Reconnoiter&lt;/a&gt;.  noitd, the agent responsible for performing active checks against other systems, has a high-performance hybrid thread/event core.  Writing code for a hybrid thread/event system can be quite mind bending to write and challenging to debug.  Reconnoiter allows writing checks as modules that are dynamically loaded into the system at run-time.  The hybrid thread/event core means that the core itself is capable of handing hundreds of thousands of open sockets (think network connections).  Writing complex event-driven C code severely limits the audience that can contribute check code to this open source project.  This frames the need.&lt;/p&gt;

&lt;p&gt;Managing hundreds of thousands of concurrent threads in the system is a recipe for suboptimal performance.  In order to remove the complexity of event-driven programming, I need to extend Reconnoiter&amp;#8217;s core to a language that could provide the feel of a procedural (or OO) programming atmosphere while maintaining a non-blocking, continuation based implementation for high single-system concurrency.&lt;/p&gt;

&lt;p&gt;Now, this is possible (sort of) with many of the embedding choices. When I get to a point in the interpreted code where I need to suspend what I&amp;#8217;m doing and complete it later when actionable data is available (say date from a network read)  to take some action.  The issue is that in order to resume all these languages where they left off, I need to maintain their C stacks.  This can be accomplished with a user-space threading implementation strategy using setjmp, longjmp and a healthy sprinkling of black magic.  In a lot of ways, this approach doesn&amp;#8217;t solve the problem if requiring a interpreter or VM thread for each concurrent operation which would voraciously consume resources.&lt;/p&gt;

&lt;p&gt;Enter lua, champion of concurrency.  lua is a stack based virtual machine specifically designed for integration with larger C systems.  Within lua, assuming you don&amp;#8217;t use any third-party extensions (of which there are few), I can leverage the &lt;a href=&quot;http://www.lua.org/manual/5.1/manual.html#lua_yield&quot;&gt;lua_yield&lt;/a&gt; and &lt;a href=&quot;http://www.lua.org/manual/5.1/manual.html#lua_resume&quot;&gt;lua_resume&lt;/a&gt; API calls to suspend the execution of a lua co-routine (lua-space thread) without the need of capturing a C stack.  The state of lua&amp;#8217;s execution is represented in the lua stack and simply pick up later right were I left off.  This is a technical nuance, but one that provides a considerable amount of freedom.  In a single thread, I can open 100k network sockets and have them all independently driven by lua programs without maintaining 100k C stacks.  Furthermore, the lua programs give the feel of blocking reads and writes making network programming once again bearable.&lt;/p&gt;

&lt;p&gt;After wrapping Reconnoiter&amp;#8217;s &lt;a href=&quot;https://labs.omniti.com/trac/reconnoiter/browser/trunk/src/eventer&quot;&gt;libeventer&lt;/a&gt; and check systems with lua, I was able to replace the previous incarnations of our HTTP checker (based on libserf, then on libcurl) with a 170 line lua &lt;a href=&quot;https://labs.omniti.com/trac/reconnoiter/browser/trunk/src/modules-lua/noit/HttpClient.lua&quot;&gt;HttpClient&lt;/a&gt; that consumes less memory and less CPU!   If you&amp;#8217;re wondering, yes, the client supports chunked transfer encoding, gzip/deflate content encoding, arbitrary headers, client payloads and methods.&lt;/p&gt;

&lt;p&gt;So, despite not really liking lua as a language (I find its syntax a bit painful), the simplicity of embedding it my application was on par with Java, the fact that it is truly interpreted (no compiling lua before it will run) and the absolutely brilliant exposure of its continuations as first-class embedding APIs puts me in bed with lua.&lt;/p&gt;

&lt;h3&gt;Summation&lt;/h3&gt;

&lt;p&gt;Never embed a language just to embed a language; always have a purpose in mind.  Understand the host architecture in which you need to embed and attempt to match the strong points of a particular interpreter or VM to your needs.  For example, if you have a heavily threaded host architecture, don&amp;#8217;t embed something that doesn&amp;#8217;t support threading well (or claims to but takes global locks).&lt;/p&gt;

&lt;p&gt;Next time I embed, I will start with three preferences: Java, Javascript and Lua.  Sadly, I predict Javascript will be disqualified quickly due to its deficiencies.  Java and Lua both have that pros and cons.  I just hope the next project finds Lua the best bedmate, I&amp;#8217;m already looking forward to working with it again.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Tue, 06 Oct 2009 22:21:48 -0400</pubDate>
    <guid isPermaLink="false">http://lethargy.org/~jesus/writes/165</guid>
    
</item>
<item>
    <title>A look at rubyrep</title>
    <link>http://lethargy.org/~jesus/writes/a-look-at-rubyrep</link>
            <category>OpenSolaris</category>
            <category>PostgreSQL</category>
    
    <comments>http://lethargy.org/~jesus/writes/a-look-at-rubyrep#comments</comments>
    <wfw:comment>http://lethargy.org/~jesus/wfwcomment.php?cid=163</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://lethargy.org/~jesus/rss.php?version=2.0&amp;type=comments&amp;cid=163</wfw:commentRss>
    

    <author>nospam@example.com (Theo Schlossnagle)</author>
    <content:encoded>
    &lt;p&gt;&lt;a href=&quot;http://denishjpatel.blogspot.com/2009/08/yet-another-postgresql-replication-tool.html&quot;&gt;rubyrep looks neat&lt;/a&gt;.  I suppose &lt;a href=&quot;http://omniti.com&quot;&gt;our&lt;/a&gt; next round of tests will have to use it on some billion row tables and see how it fairs.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Thu, 20 Aug 2009 15:27:12 -0400</pubDate>
    <guid isPermaLink="false">http://lethargy.org/~jesus/writes/163</guid>
    
</item>
<item>
    <title>highscalability.com talks about OmniTI's Reconnoiter</title>
    <link>http://lethargy.org/~jesus/writes/highscalabilitycom-talks-about-omnitis-reconnoiter</link>
            <category>OpenSolaris</category>
            <category>PostgreSQL</category>
    
    <comments>http://lethargy.org/~jesus/writes/highscalabilitycom-talks-about-omnitis-reconnoiter#comments</comments>
    <wfw:comment>http://lethargy.org/~jesus/wfwcomment.php?cid=162</wfw:comment>

    <slash:comments>4</slash:comments>
    <wfw:commentRss>http://lethargy.org/~jesus/rss.php?version=2.0&amp;type=comments&amp;cid=162</wfw:commentRss>
    

    <author>nospam@example.com (Theo Schlossnagle)</author>
    <content:encoded>
    &lt;p&gt;It&amp;#8217;s exciting to see things starting to take off.  The momentum and excitement around &lt;a href=&quot;http://labs.omniti.com/trac/reconnoiter/&quot;&gt;Reconnoiter&lt;/a&gt; are at an all time high here at &lt;a href=&quot;http://omniti.com/&quot;&gt;OmniTI&lt;/a&gt;.  I really appreciate Todd Herr&amp;#8217;s &lt;a href=&quot;http://highscalability.com/reconnoiter-large-scale-trending-and-fault-detection&quot;&gt;extensive write up about Reconnoiter&lt;/a&gt; over at &lt;a href=&quot;http://highscalability.com/&quot;&gt;highscalability.com&lt;/a&gt; &amp;#8212; the review was spot on.&lt;/p&gt;

&lt;p&gt;It has ample criticism (all deserved) and we&amp;#8217;re continuing to work on the &amp;#8220;consumability&amp;#8221; aspects of the product.  One of the comments he made was the interesting choice of &lt;a href=&quot;http://lua.org/&quot;&gt;Lua&lt;/a&gt; as a language to extend the product.  I really wanted to use Perl or Python to extend Reconnoiter, but Lua has some pretty magical properties that made it meld well with the noit internals.  In my opinion it is perhaps one of the more technically interesting parts of the product as the search was long and the choice reluctant.  When I have more time, I&amp;#8217;ll write an article about embedding lua in noit and the deeper reasoning behind it.&lt;/p&gt;

&lt;p&gt;Also, don&amp;#8217;t be scared by Lua, you can always write extensions in C!  Although it doesn&amp;#8217;t meld well with its high performance design, there is an &lt;code&gt;extproc&lt;/code&gt; module that allows writing checks as standalone scripts and operates fine with existing &lt;a href=&quot;http://nagios.org/&quot;&gt;Nagios&lt;/a&gt; checks &amp;#8212; I say I wrote it to make adoption a bit easier, but in truth &lt;a href=&quot;http://omniti.com/is/eric-sproul&quot;&gt;Eric&lt;/a&gt; and &lt;a href=&quot;http://omniti.com/is/mark-harrison&quot;&gt;Mark&lt;/a&gt; made me do it.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Sun, 16 Aug 2009 15:13:07 -0400</pubDate>
    <guid isPermaLink="false">http://lethargy.org/~jesus/writes/162</guid>
    
</item>
<item>
    <title>Big Bad Postgres Indeed</title>
    <link>http://lethargy.org/~jesus/writes/big-bad-postgres-indeed</link>
            <category>OpenSolaris</category>
            <category>PostgreSQL</category>
    
    <comments>http://lethargy.org/~jesus/writes/big-bad-postgres-indeed#comments</comments>
    <wfw:comment>http://lethargy.org/~jesus/wfwcomment.php?cid=161</wfw:comment>

    <slash:comments>1</slash:comments>
    <wfw:commentRss>http://lethargy.org/~jesus/rss.php?version=2.0&amp;type=comments&amp;cid=161</wfw:commentRss>
    

    <author>nospam@example.com (Theo Schlossnagle)</author>
    <content:encoded>
    &lt;p&gt;I gave a talk at the Percona Performance conference (same time as MySQL, in the same facility... can we say awkward?) about running large PostgreSQL installs.  I referred to a few instances in the presentation that are a handful of terabytes in size.  In today&#039;s world, these aren&#039;t that large, however we do pretty deep analytics on these installs.  It is most definitely not a case of store and forget.&lt;/p&gt;

&lt;p&gt;A few people came up and said: &quot;I thought you were going to talk about big... a terabyte is not big.&quot;  I would rebut that with it&#039;s not how big it is, it is what you do with it, but then I would be on the defensive.  The truth of the matter is that it is a combination of things.  Size matters: below a certain threshold, you simple can&#039;t call it large.  Usage matters: if you don&#039;t do something interesting with the data, you might as well be throwing it away.  While most of the PostgreSQL instances we deal with were considered larger by 2005 standards, a terabyte simply no longer meets the bare minimum for &quot;large.&quot;&lt;/p&gt;

&lt;p&gt;I&#039;m excited that we&#039;re looking to launch a new service that will turn the tables on large for PostgreSQL.  We very well could have 10 petabytes in postgres in no time if things go as planned.  Not only will we meet the size requirements, we&#039;ll also be doing lots of interesting things with the data.  Big Bad PostgreSQL indeed.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Mon, 10 Aug 2009 21:45:39 -0400</pubDate>
    <guid isPermaLink="false">http://lethargy.org/~jesus/writes/161</guid>
    
</item>
<item>
    <title>Make the web a faster place.  Pretty please.</title>
    <link>http://lethargy.org/~jesus/writes/make-the-web-a-faster-place-pretty-please</link>
            <category>BWPUG</category>
            <category>Damaged Bits</category>
            <category>OpenSolaris</category>
            <category>PostgreSQL</category>
    
    <comments>http://lethargy.org/~jesus/writes/make-the-web-a-faster-place-pretty-please#comments</comments>
    <wfw:comment>http://lethargy.org/~jesus/wfwcomment.php?cid=157</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://lethargy.org/~jesus/rss.php?version=2.0&amp;type=comments&amp;cid=157</wfw:commentRss>
    

    <author>nospam@example.com (Theo Schlossnagle)</author>
    <content:encoded>
    &lt;p&gt;Call to action!  Make the web a faster place!  Here&#039;s a short &lt;a href=&quot;http://omniti.com/seeds/yslow-to-yfast-in-45-minutes&quot;&gt;article on how I spent 45 minutes to improve user-perceived performance&lt;/a&gt; on &lt;a href=&quot;http://omniti.com/&quot;&gt;our website&lt;/a&gt;.  This is the low-hanging fruit of front-end web performance optimizations.&lt;/p&gt;

&lt;p&gt;Most of you who read my blog are scalability or performance nuts.  Most of you also cast the majority of your focus (like me) on the back-end infrastructure problems.  Don&#039;t ignore the front-end when just a tiny bit of work can remove a huge amount of suck.&lt;/p&gt;

&lt;p&gt;If everyone takes these steps, the web will be a more enjoyable place to visit.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Tue, 07 Jul 2009 10:36:59 -0400</pubDate>
    <guid isPermaLink="false">http://lethargy.org/~jesus/writes/157</guid>
    
</item>
<item>
    <title>Web: you can now not suck.</title>
    <link>http://lethargy.org/~jesus/writes/web-you-can-now-not-suck</link>
            <category>Damaged Bits</category>
            <category>OpenSolaris</category>
            <category>PostgreSQL</category>
    
    <comments>http://lethargy.org/~jesus/writes/web-you-can-now-not-suck#comments</comments>
    <wfw:comment>http://lethargy.org/~jesus/wfwcomment.php?cid=156</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://lethargy.org/~jesus/rss.php?version=2.0&amp;type=comments&amp;cid=156</wfw:commentRss>
    

    <author>nospam@example.com (Theo Schlossnagle)</author>
    <content:encoded>
    &lt;img src=&quot;http://images.omniti.net/lethargy.org/~jesus/uploads/velocity2009_160x600.gif&quot; alt=&quot;&quot; style=&quot;margin-left: 2em; margin-bottom:1em; float:right;&quot;/&gt;
&lt;p&gt;In perhaps a new trend, I&amp;#8217;m blogging from 39011 feet (or so says the seatback in front of me).  I&amp;#8217;m traveling back home to the east coast from San Jose, CA where I attended (and spoke) at this year&amp;#8217;s &lt;a href=&quot;http://en.oreilly.com/velocity2009/&quot;&gt;O&amp;#8217;Reilly Velocity Conference&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I participated (and blogged) about the Velocity Summit in which I&amp;#8217;ve participated for the past two years.  The summit is the unconference preceding the real conference that help the organizers digest current hot topics and better define the conference track for the actual conference.  The summit itself is filled with enough brain power to warp space-time, so I drop everything to go to that.&lt;/p&gt;

&lt;p&gt;Ironically, despite being a well respected authority in web site (and general internet) scalability and performance, my talk proposals for Velocity 2008 were not accepted &amp;#8212; I clearly need to write better proposals.  This year, I managed to work my way into the workshop track on Monday.  Despite having a bad headache and feeling &quot;off&quot; the day before, I managed to get my act together and put on an A-game for my workshop.  For those of you interested, here is &lt;a href=&quot;http://www.slideshare.net/postwait/scalable-internet-architecture&quot;&gt;my scalable09 slide stack&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I thought I&amp;#8217;d take a moment to talk about what I liked about the conference and what I think could use some improvement.  I realize this is a down economy and that might be a legitimate justification for some the actions that resulted in some of my disappointment.&lt;/p&gt;

&lt;p&gt;First, the negative.  I usually start with positive and end with negative because I&amp;#8217;m a pessimist.  However, all in all the conference was awesome, so I thought I&amp;#8217;d get my short list of gripes out of the way early.&lt;/p&gt;

&lt;p&gt;O&amp;#8217;Reilly is infamous for throwing good conferences for geeks.  In my opinion, the field of web operations has been so severely neglected and applies so broadly to the world today that this conference needs to be for everyone.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In the next conference, I&amp;#8217;d love to see a technical business track.  Several of the talks I went to spoke to the dollars and cents lost or earned by paying the right amount of attention to web site performance and better operational paradigms.  I thought a lot of the topics would be very useful to business managers.&lt;/li&gt;
&lt;li&gt;The first day was not video taped and the second and third day were only half video taped.  Come on guys, ante up.  The attendance fee was substantial, you can afford to give your attendees the value of watching what they had to choose not to attend.  I like the option when I go to a conference to choose a session that seems interesting so that I have the opportunity to participate, but often times I find that another session was top notch and I &lt;em&gt;expect&lt;/em&gt; to be able to later review a recording of that.&lt;/li&gt;
&lt;li&gt;Lastly, and this is the most significant.  While I thought the conference was extremely well executed (excellent job Jesse, Steve, all your support, and most definitely O&amp;#8217;Reilly), it lacked sufficient PR and marketing outreach.  I talked with several journalists (as a part of my normal day job) while I was at that conference and &lt;em&gt;not one&lt;/em&gt; of them was aware of Velocity &amp;#8212; simply embarrassing.  Given that the Structure conference was in town that same week, O&amp;#8217;Reilly should have invested more in their PR and marketing outreach.  It would have resulted in a substantially increased audience and a better venue for teaching the world to run a faster web.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now that I&amp;#8217;ve griped and aired my disappointment.  I can focus on the gobs of awesomeness that was Velocity.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The conference was put on quite well from an operational perspective.  Things started on time, A/V problems were non-existent.  Like an idiot, I managed to lose my MacBook Air power adapter and the A/V crew managed to recover it for me.  Conferences just plain suck when they have technical difficulties; this one had none.&lt;/li&gt;
&lt;li&gt;The two tracks at the conference were extremely well articulated and while I wanted to be in both all the time (as OmniTI is a full-stack company, we care about both equally) it was an excellent split.&lt;/li&gt;
&lt;li&gt;One track was performance which focused intently on user-perceived performance.  This was largely front-end (HTML,CSS,JS,etc.) but also had a healthy amount of deep stack performance discussion as well including the often ignored, but much deserving networking aspect of delivering the web to users.&lt;/li&gt;
&lt;li&gt;The second track was operations and I feared it would be bunch of blind &amp;#8220;The Cloud Solves All Our Problems&amp;#8221; sessions.  Much to the contrary, it focused heavily on operational strategy and and what it takes to execute tactically.  There was a bit of cloud here and there (okay everywhere), but there was very little blind and ignorant mentality that launching in the cloud was a solution to a hard scaling problem.&lt;/li&gt;
&lt;li&gt;I had the opportunity to see a lot of old faces, but spent most of my time meeting new ones.  The opportunity to learn more about other people&amp;#8217;s problems is what completes me as an engineer.  The people I met at this conference were both honest and open and provided a fabulous and refreshing perspective on what today&amp;#8217;s performance and scalability problems really are.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;
In my workshop, I spent about 20% of the time discussing the philosophy of being a good engineer and 80% discussing practice (non-cookbook) with examples and advice.  The basic message is that systems are complex and you must think of all the parts holistically or its a recipe for disaster &amp;#8212; or failure.
&lt;/p&gt;

&lt;p&gt;
Two of my favorite talks were Nicole Sullivan&#039;s &amp;#8220;The Fast and the Fabulous: 9 ways engineering and design come together to make your site slow&amp;#8221; and &amp;#8220; 10+ Deploys Per Day: Dev and Ops Cooperation at Flickr&amp;#8221; by John Allspaw and Paul Hammond.  While Nicole&#039;s presentation, like mine, was not recorded, the other was and if you want to break down the divide between operations and development, it is a &lt;a href=&quot;http://velocityconference.blip.tv/file/2284377/&quot;&gt;must see.&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;All in all, I would encourage everyone reading this to attend next year&#039;s Velocity conference.  I am certain you will walk away with knowledge that is both valuable and applicable.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Thu, 25 Jun 2009 23:33:33 -0400</pubDate>
    <guid isPermaLink="false">http://lethargy.org/~jesus/writes/156</guid>
    
</item>
<item>
    <title>What time is it?</title>
    <link>http://lethargy.org/~jesus/writes/what-time-is-it</link>
            <category>PostgreSQL</category>
    
    <comments>http://lethargy.org/~jesus/writes/what-time-is-it#comments</comments>
    <wfw:comment>http://lethargy.org/~jesus/wfwcomment.php?cid=155</wfw:comment>

    <slash:comments>5</slash:comments>
    <wfw:commentRss>http://lethargy.org/~jesus/rss.php?version=2.0&amp;type=comments&amp;cid=155</wfw:commentRss>
    

    <author>nospam@example.com (Theo Schlossnagle)</author>
    <content:encoded>
    &lt;p&gt;&lt;a href=&quot;http://postgresql.org/&quot;&gt;PostgreSQL&lt;/a&gt; has pretty &lt;a href=&quot;http://www.postgresql.org/docs/8.3/static/functions-datetime.html&quot;&gt;awesome date/time functionality&lt;/a&gt;.  I&#039;ve used a lot of database and the functionality and thoroughness of the treatment of dates and times (and particularly timezones) is unparalleled.  As much as I&#039;m impressed with it, I knew there would come a time where the outcome of all that cleverness would backfire.&lt;/p&gt;

&lt;p&gt;Recently, I was &lt;a href=&quot;http://labs.omniti.com/trac/reconnoiter/ticket/140&quot;&gt;doing some data partitioning&lt;/a&gt;.  I split a couple of largish (approximately billion row) tables up into month segments.  I wrote a tiny little pl/pgsql function that takes a parent table, and creates an inherited child with the right indexes, triggers, check constraints (for constraint exclusion) and permissions.  I renamed the big table something transient, created a new parent table with the old table&#039;s name, made the old unwieldy table a child of that table and then created a whole bunch of new partitions.  This allowed me to pretty much ignore my shenanigans from the application side. Once I created the partitions, I need to back populate them.  To do this, I did the following:&lt;/p&gt;

&lt;pre&gt;
ALTER TABLE newchildtable_200903 DISABLE TRIGGER ALL;
INSERT INTO newchildtable_200903
  SELECT * FROM oldcrappytable
  WHERE whence &gt;= &#039;2009-03-01 00:00:00-00&#039;::timestamptz
      AND whence &lt; &#039;2009-03-01 00:00:00-00&#039;::timstamptz + &#039;1 month&#039;::interval;
DELETE FROM oldcrappytable
  WHERE whence &gt;= &#039;2009-03-01 00:00:00-00&#039;::timestamptz
      AND whence &lt; &#039;2009-03-01 00:00:00-00&#039;::timstamptz + &#039;1 month&#039;::interval;
ALTER TABLE newchildtable_200903 ENABLE TRIGGER ALL;
&lt;/pre&gt;

&lt;p&gt;Suffice it to say, this did not do what I wanted &lt;em&gt;at all&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;PostgreSQL&#039;s interval type is one of its more clever features.  The idea that a month isn&#039;t always equal to a month is a Gregorian truism.  So, PostgreSQL is design to &quot;do the right thing&quot; and consider a month in the context of another argument.  A month in the above example is a month with respect to March.  Right?  No.&lt;/p&gt;

&lt;p&gt;The lacking part here is the timezone.  I do the partitioning in UTC (because I&#039;m not insane).  So, I need the month of March in UTC.  Although I explicitly stated &#039;2009-03-01 00:00:00-00&#039; in UTC, PostgreSQL interprets that in the client&#039;s timezone... and &lt;em&gt;then&lt;/em&gt; adds a month.  I&#039;m in US/Eastern which is &lt;em&gt;trailing&lt;/em&gt; UTC by four or five hours and thus the reference starting point is actually in February of 2009, which only had 28 days.  So, the latter inequality up there does not do through the end of March!&lt;/p&gt;

&lt;p&gt;I would argue that this behavior is invalid, because of the extremely unexpected results of the following simple test case:&lt;/p&gt;

&lt;pre&gt;
postgres=# select (&#039;2009-03-01 00:00:00-00&#039;::timestamptz + &#039;1 month&#039;::interval);
2009-03-28 19:00:00-04

postgres=# set timezone = &#039;utc&#039;;
SET

postgres=# select (&#039;2009-03-01 00:00:00-00&#039;::timestamptz + &#039;1 month&#039;::interval);
2009-04-01 00:00:00+00
&lt;/pre&gt;

&lt;p&gt;Here I get a &lt;em&gt;completely&lt;/em&gt; different date/time if I ask what appears to be a very unambiguous question depending on whether I&#039;m left or right of the &lt;a href=&quot;http://en.wikipedia.org/wiki/Prime_meridian&quot;&gt;Prime Meridian&lt;/a&gt;. 
    </content:encoded>

    <pubDate>Tue, 16 Jun 2009 15:28:40 -0400</pubDate>
    <guid isPermaLink="false">http://lethargy.org/~jesus/writes/155</guid>
    
</item>
<item>
    <title>Cloud storage primer</title>
    <link>http://lethargy.org/~jesus/writes/cloud-storage-primer</link>
            <category>Damaged Bits</category>
            <category>OpenSolaris</category>
            <category>PostgreSQL</category>
    
    <comments>http://lethargy.org/~jesus/writes/cloud-storage-primer#comments</comments>
    <wfw:comment>http://lethargy.org/~jesus/wfwcomment.php?cid=154</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://lethargy.org/~jesus/rss.php?version=2.0&amp;type=comments&amp;cid=154</wfw:commentRss>
    

    <author>nospam@example.com (Theo Schlossnagle)</author>
    <content:encoded>
    &lt;p&gt;I post here, I post there... I certainly don&#039;t post everywhere.  Anyway, I wrote an article that &lt;a href=&quot;http://omniti.com/seeds/concepts-of-cloudish-storage&quot;&gt;discusses the basic technologies that power large cloud-like storage systems&lt;/a&gt;.  Thought you might be interested.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Thu, 11 Jun 2009 16:41:27 -0400</pubDate>
    <guid isPermaLink="false">http://lethargy.org/~jesus/writes/154</guid>
    
</item>

</channel>
</rss>