fix 9.1 support
[gevel.git] / README.gevel
index d4981b9..35b81d1 100644 (file)
@@ -1,13 +1,13 @@
-Gevel contrib module provides several functions useful for analyzing GiST index.
+Gevel contrib module provides several functions useful for analyzing GiST and GIN index.
 
 [Online version] of this document (http://www.sai.msu.su/~megera/oddmuse/index.cgi/Gevel)
 
-Caution: This module was designed for developers of GiST based indices !
+Caution: This module was designed for advanced users of GIN, GiST and SP-GiST indices !
 
 Authors
 
     * Oleg Bartunov <oleg@sai.msu.su>, Moscow, Moscow University, Russia
-    * Teodor Sigaev <teodor@sigaev.ru>, Moscow, Delta-Soft Ltd.,Russia
+    * Teodor Sigaev <teodor@sigaev.ru>, Moscow, Moscow University, Russia
 
 License
 
@@ -122,3 +122,76 @@ regression=# select gist_tree('pix');
      1 | t     | (31179,50040),(28113,25556)
      1 | t     | (28048,49694),(25000,25000)
 (29 rows)
+
+    * spgist_stat(INDEXNAME) - show some statistics about SP-GiST tree
+# SELECT spgist_stat('spgist_idx');
+           spgist_stat            
+----------------------------------
+ totalPages:        21           +
+ deletedPages:      0            +
+ innerPages:        3            +
+ leafPages:         18           +
+ emptyPages:        1            +
+ usedSpace:         121.27 kbytes+
+ freeSpace:         46.07 kbytes +
+ fillRatio:         72.47%       +
+ leafTuples:        3669         +
+ innerTuples:       20           +
+ innerAllTheSame:   0            +
+ leafPlaceholders:  569          +
+ innerPlaceholders: 0            +
+ leafRedirects:     0            +
+ innerRedirects:    0
+
+    * spgist_print(INDEXNAME) - prints objects stored in GiST tree, 
+     works only if objects in index have textual representation 
+     (type_out functions should be implemented for given object type).
+        Note 1. in example below we used quad_point_ops which uses point
+               for leaf and prefix value, but doesn't use node_label at all.
+               Use type  'int' as dummy type for prefix or/and node_label.
+        Note 2
+               quad_point_ops: prefix point, node_label int,  leaf_value point
+               kd_point_ops:   prefix float, node_label int,  leaf_value point
+               text_ops:       prefix text,  node_label char, leaf_value text
+
+# SELECT * FROM spgist_print('spgist_idx') as t
+               (
+                       tid tid, 
+                       node_n int, 
+                       level int, 
+                       tid_pointer tid, 
+                       prefix point, 
+                       node_label int, 
+                       leaf_value point
+               ) where level = 1;
+  tid  | node_n | level | tid_pointer |               prefix                | node_label | leaf_value 
+-------+--------+-------+-------------+-------------------------------------+------------+------------
+ (1,1) |      0 |     1 | (5,4)       | (24530.2070484581,23595.7092511013) |            | 
+ (1,1) |      1 |     1 | (5,3)       | (24530.2070484581,23595.7092511013) |            | 
+ (1,1) |      2 |     1 | (5,2)       | (24530.2070484581,23595.7092511013) |            | 
+ (1,1) |      3 |     1 | (5,1)       | (24530.2070484581,23595.7092511013) |            | 
+
+   * gin_stat(INDEXNAME) prints estimated counts for each indexed values
+        Note: since 8.4 gin_stat function has gin_stat(INDEXNAME, COLNUMBER) 
+        prototype, single-argument function will return result for a first
+        column of index
+
+# SELECT * FROM gin_stat('gin_idx') as t(value int, nrow int) where nrow > 250;
+ value | nrow 
+ -------+------
+       31 |  254
+       47 |  251
+       52 |  257
+       59 |  259
+ (4 rows)
+
+   * bigint gin_count_estimate(INDEXNAME, TSQUERY) outputs number of indexed
+        rows matched query. It doesn't touch heap at all.
+
+# select gin_count_estimate('qq', 'star');
+ gin_count_estimate 
+--------------------
+                                790
+(1 row)
+