From 8c73dfcc8b7801dcc6a46157ea5bd3aacedcea3f Mon Sep 17 00:00:00 2001
From: Teodor Sigaev <teodor@sigaev.ru>
Date: Mon, 3 Oct 2005 14:41:42 +0000
Subject: [PATCH] Optimize benchmark query and update benchmark's results.

---
 contrib/intarray/README.intarray | 22 +++++++++++-----------
 contrib/intarray/bench/bench.pl  |  4 +++-
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/contrib/intarray/README.intarray b/contrib/intarray/README.intarray
index f850deebcea..9c3ecbe2615 100644
--- a/contrib/intarray/README.intarray
+++ b/contrib/intarray/README.intarray
@@ -144,21 +144,21 @@ BENCHMARK:
                   see availbale options.
 
      a)test without RD-Tree (OR)
-       ./bench.pl -d TEST -s 1,2 -v
+       ./bench.pl -d TEST -c -s 1,2 -v
      b)test with RD-Tree 
-       ./bench.pl -d TEST -s 1,2 -v -r
+       ./bench.pl -d TEST -c -s 1,2 -v -r
 
 BENCHMARKS:
 
 Size of table <message>: 200000
-Size of table <message_section_map>: 268538 
+Size of table <message_section_map>: 269133 
 
 Distribution of messages by sections:
 
-section 0: 73899 messages
-section 1: 16298 messages
-section 50: 1241 messages
-section 99: 705 messages
+section 0: 74377 messages
+section 1: 16284 messages
+section 50: 1229 messages
+section 99: 683 messages
 
 old - without RD-Tree support,
 new - with RD-Tree
@@ -168,11 +168,11 @@ new - with RD-Tree
 |          +-------+-------+--------+-------+
 |          |  old  |  new  |   old  |  new  |
 +----------+-------+-------+--------+-------+
-|         1|  1.427|  0.215|       -|      -|
+|         1|  0.625|  0.101|       -|      -|
 +----------+-------+-------+--------+-------+
-|        99|  1.029|  0.018|       -|      -|
+|        99|  0.018|  0.017|       -|      -|
 +----------+-------+-------+--------+-------+
-|       1,2|  1.829|  0.334|   5.654|  0.042|
+|       1,2|  0.766|  0.133|   0.628|  0.045|
 +----------+-------+-------+--------+-------+
-| 1,2,50,60|  2.057|  0.359|   5.044|  0.007|
+| 1,2,50,65|  0.794|  0.141|   0.030|  0.006|
 +----------+-------+-------+--------+-------+
diff --git a/contrib/intarray/bench/bench.pl b/contrib/intarray/bench/bench.pl
index 2e30956721c..66df02dfc11 100755
--- a/contrib/intarray/bench/bench.pl
+++ b/contrib/intarray/bench/bench.pl
@@ -42,7 +42,9 @@ if ( $opt{a} ) {
 		push @where, "message.sections @ '{$opt{s}}'";
 	} else {
 		foreach my $sid ( split(/[,\s]+/, $opt{s} )) {
-			push @where, "EXISTS ( select  message_section_map.mid from message_section_map where message.mid=message_section_map.mid and message_section_map.sid = $sid )";
+			push @where, "message.mid = msp$sid.mid";
+			push @where, "msp$sid.sid = $sid";
+			$table{"message_section_map msp$sid"}=1;
 		}
 	}
 } else {
-- 
GitLab