[MTOS-dev] Performance

Hirotaka Ogawa hirotaka.ogawa at gmail.com
Thu Mar 6 08:34:11 PST 2008


I filed this patch: http://bugs.movabletype.org/default.asp?69661

On Tue, Mar 4, 2008 at 1:53 PM, Hirotaka Ogawa <hirotaka.ogawa at gmail.com> wrote:
>
> On Tue, Mar 4, 2008 at 4:37 AM, Alvar Freude <alvar at a-blast.org> wrote:
>  > Hi,
>  >
>  >
>  >  -- Hirotaka Ogawa <hirotaka.ogawa at gmail.com> wrote:
>  >
>  >  > I think, adding a new published entry is a relatively large
>  >  > transaction.  I'd like to know analysis for more minute operations if
>  >  > you can.
>  >
>  >  I'm not at home this week and have only highly firewalled internet at my
>  >  client's office and tired in the hotel, so I might be even more slow this
>  >  week than usually ...
>  >
>  >
>  >
>  >  ># 133 "SELECT COUNT(*)" queries is probably for determining
>  >  > unique_basename.  Actually, it is one of the most inefficient
>  >  > subroutines in MT.
>  >
>  >  There is one COUNT(*) from this, but this should be fast as there is an
>  >  index on mt_entry.entry_basename.
>  >
>  >  But, nevertheless, the COUNT(*) SQL may be often changed to somethink
>  >  like:
>  >
>  >   SELECT 1
>  >   FROM mt_comment
>  >   WHERE comment_visible=1 AND
>  >         comment_entry_id=123
>  >   LIMIT 1;
>  >
>  >
>  >  With PostgreSQL and a table with about 3500 entries this is about 30%
>  >  faster.
>  >
>  >  For this there may be a new method "exist" or something like this in
>  >  MT::ObjectDriver::Driver::DBI which can be called when a boolean "exists"
>  >  value is needed. I think this would be also more clean then counting.
>
>  So, after applying attached patch, can you please run a small benchmark as like:
>
>  ---
>  #!/usr/bin/perl
>
>  use strict;
>  use warnings;
>  use lib 'lib';
>  use lib 'extlib';
>
>  use Time::HiRes qw( gettimeofday tv_interval );
>  use MT;
>
>  my $count = shift || 1000;
>  my $mt = MT->new;
>
>  # Change this!
>  my $term = {
>     blog_id => 1,
>     basename => 'post',
>  };
>
>  my $t0 = [gettimeofday];
>  for (my $i = 0; $i < $count; $i++) {
>     MT::Entry->exist($term);
>  }
>  print "MT::Entry->exist: " . tv_interval($t0, [gettimeofday]) . "\n";
>
>  $t0 = [gettimeofday];
>  for (my $i = 0; $i < $count; $i++) {
>     MT::Entry->count($term);
>  }
>  print "MT::Entry->count: " . tv_interval($t0, [gettimeofday]) . "\n";
>
>  1;
>  ---
>
>  If 'exist' is faster than 'count', it is worth the extra effort to
>  rewrite MT to use it.
>
>
>  >
>  >
>  >
>  >
>  >  Ciao
>  >   Alvar
>  >
>  >  --
>  >  ** Alvar C.H. Freude, http://alvar.a-blast.org/
>  >  ** http://www.assoziations-blaster.de/
>  >  ** http://www.wen-waehlen.de/
>  >  ** http://odem.org/
>  >
>
>
>
>
>
> --
>  Hirotaka Ogawa makes no sense.
>  http://as-is.net/blog/
>



-- 
Hirotaka Ogawa makes no sense.
http://as-is.net/blog/


More information about the MTOS-dev mailing list