Subject: Maximum extents
From: Tim Schaefer <[email-masked]>
Date: Tue, 14 Jan 1997 21:48:51 -0500
Newsgroups: comp.databases.informix

>      Hi all,
> 
>      Does anybody know the maximum number of extents for one tablespace ?
> 
>      Thanks in advance.
> 

Ok,  I waited like a good boy for others to post a solution.
Here's a C-language program to get you started, and the Java version.
However, I think if you ask Jonathan nicely, he might send you his thesis on 
this, a rather nice collection of programs that will help you stay 
distracted for a year on this topic...  :-)

I must add that these two programs are by no means definitive, and purely
experimental.  Fly no higher than you're willing to fall.  The Java was done
with the Visual Cafe Java thingy from Symantec. 

Enjoy!

/*******************************************************************************
 maxextents.c: Determines the total number of INFORMIX extents for a table based 
               on a few parameters.
       Author: Tim Schaefer, Copyright 1996 All Rights Reserved
    Reference: Informix Guide to SQL Tutorial Version 4.1, July 1991
               Informix Press, Part No. 000-7028
*******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

main( argc, argv )
int argc ;
int **argv ;
{
int pagesize = 0 ; /* BUFFSIZE 2048     */
int colspace = 0 ; /* # of cols         */
int idxspace = 0 ; /* # of idxs         */
int idxparts = 0 ; /* # of cols in idxs */

int numcols  = 0 ;
int numidxs  = 0 ;
int numidxp  = 0 ;
int calc1    = 0 ;
int calc2    = 0 ;

float extspace = 0.00 ;
int maxetxsp = 0 ;

int pageuse  = 0 ;
int rowsize  = 0 ;
int homerow  = 0 ;
int overpage = 0 ;
int homemax  = 0 ;

if ( argc != 1 )
   {
    pagesize = atoi( argv[1] ) ;
    numcols  = atoi( argv[2] ) ;
    numidxs  = atoi( argv[3] ) ;
    numidxp  = atoi( argv[4] ) ;
   if ( numidxs == 0 ) 
      { 
      idxspace = 0 ;
      }
   else
      {
      idxspace = 12 * numidxs ;
      }  
   colspace = 4 * numcols ;
   pageuse  = pagesize - 28 ;
   calc1    = colspace + idxspace + idxparts + 84 ;
   extspace = pagesize - calc1 ;
   calc2    = extspace / 8 ;
   printf("Max Extents  [%d]\n", calc2 );
   }
else
   {
   printf("Usage: dbspace pagesize numcols numidxs numidxparts \n" ) ;
   print ("where: \n" );
   printf("pagesize    - page size known as BUFFSIZE in tbstat -c output \n" ) ;
   printf("numcols     - total number of columns in a table\n" ) ;
   printf("numidxs     - total number of indexes in a table\n" ) ;
   printf("numidxparts - total number of columns in each index \n" ) ;
   }
}

END C PROGRAM

And here's the Java version of the same program:

/*
    A basic extension of the java.applet.Applet class

 */

import java.awt.*;
import java.applet.*;
import java.lang.*;

public class Applet1 extends Applet {

	void textField4_EnterHit(Event event) {
		// to do: place event handler code here.
	}

	void button1_Clicked(Event event) {
		// to do: place event handler code here.

	int pagesize = 0 ; /* BUFFSIZE 2048     */
        int colspace = 0 ; /* # of cols         */
        int idxspace = 0 ; /* # of idxs         */
        int idxparts = 0 ; /* # of cols in idxs */

        int numcols  = 0 ;
        int numidxs  = 0 ;
        int numidxp  = 0 ;
        int calc1    = 0 ;
        int calc2    = 0 ;
        int pageuse  = 0 ;
        int extspace = 0 ;

       String page_string = textField1.getText();
       pagesize = java.lang.Integer.parseInt(page_string) ;

       String ncol_string = textField2.getText();
       numcols = java.lang.Integer.parseInt(ncol_string) ;

       String nidx_string = textField5.getText();
       numidxs = java.lang.Integer.parseInt(nidx_string) ;

       String nidp_string = textField3.getText();
       numidxp = java.lang.Integer.parseInt(nidp_string) ;

       if ( numidxs == 0 )
          {
          idxspace = 0 ;
          }
       else
          {
          idxspace = 12 * numidxs ;
          }

       colspace = 4 * numcols ;
       pageuse  = pagesize - 28 ;
       calc1    = colspace + idxspace + idxparts + 84 ;
       extspace = pagesize - calc1 ;
       calc2    = extspace / 8 ;
       // printf("Max Extents  [%d]\n", calc2 );
       // System.out.println("Max Extents" + calc2 );

        page_string = java.lang.Integer.toString( calc2 );

       textField4.setText(page_string);
	}

	void button2_Clicked(Event event) {
		// to do: place event handler code here.

		textField1.setText("");
		textField2.setText("");
		textField3.setText("");
		textField4.setText("");
		textField5.setText("");
	}

	public void init() {
		super.init();

		//{{INIT_CONTROLS
		setLayout(null);
		addNotify();
		resize(575,365);
		setForeground(new Color(12632256));
		setBackground(new Color(16777215));
		label1 = new java.awt.Label("How many extents can your table have?");
		label1.reshape(95,56,444,27);
		label1.setFont(new Font("TimesRoman", Font.ITALIC, 20));
		add(label1);
		label2 = new java.awt.Label("Enter the Page Size ( BUFFSIZE )",Label.RIGHT);
		label2.reshape(102,109,319,15);
		add(label2);
		label3 = new java.awt.Label("Enter the total number of columns for this table",Label.RIGHT);
		label3.reshape(102,147,326,15);
		add(label3);
		label4 = new java.awt.Label("Enter the total number of indexes for this table",Label.RIGHT);
		label4.reshape(102,184,329,15);
		add(label4);
		label5 = new java.awt.Label("Enter the total number of columns used in all the indexes in this table",Label.RIGHT);
		label5.reshape(18,222,406,15);
		add(label5);
		textField1 = new java.awt.TextField();
		textField1.setText("2048");
		textField1.reshape(442,102,79,22);
		textField1.setForeground(new Color(0));
		add(textField1);
		textField2 = new java.awt.TextField();
		textField2.reshape(442,139,80,24);
		textField2.setForeground(new Color(0));
		add(textField2);
		textField3 = new java.awt.TextField();
		textField3.reshape(442,214,79,24);
		textField3.setForeground(new Color(0));
		add(textField3);
		textField4 = new java.awt.TextField();
		textField4.reshape(442,252,79,23);
		textField4.setForeground(new Color(0));
		add(textField4);
		button2 = new java.awt.Button("Clear Fields");
		button2.reshape(435,297,87,26);
		add(button2);
		label6 = new java.awt.Label("INFORMIX");
		label6.reshape(4,0,206,38);
		label6.setFont(new Font("Dialog", Font.PLAIN, 36));
		add(label6);
		label7 = new java.awt.Label("Maximum Allowable Extents Calculator");
		label7.reshape(196,11,336,26);
		label7.setFont(new Font("Helvetica", Font.PLAIN, 18));
		add(label7);
		textField5 = new java.awt.TextField();
		textField5.reshape(442,177,79,23);
		textField5.setForeground(new Color(0));
		add(textField5);
		label8 = new java.awt.Label("Author: Tim Schaefer, Copyright 1996 All rights reserved");
		label8.reshape(200,341,234,15);
		label8.setFont(new Font("TimesRoman", Font.PLAIN, 9));
		add(label8);
		button1 = new java.awt.Button("Calculate");
		button1.reshape(333,296,89,26);
		add(button1);
		label9 = new java.awt.Label("Total Allowable Extents for this table",Label.RIGHT);
		label9.reshape(179,259,247,15);
		add(label9);
		//}}
	}

	public boolean handleEvent(Event event) {
		if (event.target == button2 && event.id == Event.ACTION_EVENT) {
			button2_Clicked(event);
		}
		if (event.target == button1 && event.id == Event.ACTION_EVENT) {
			button1_Clicked(event);
		}

		return super.handleEvent(event);
	}

	//{{DECLARE_CONTROLS
	java.awt.Label label1;
	java.awt.Label label2;
	java.awt.Label label3;
	java.awt.Label label4;
	java.awt.Label label5;
	java.awt.TextField textField1;
	java.awt.TextField textField2;
	java.awt.TextField textField3;
	java.awt.TextField textField4;
	java.awt.Button button2;
	java.awt.Label label6;
	java.awt.Label label7;
	java.awt.TextField textField5;
	java.awt.Label label8;
	java.awt.Button button1;
	java.awt.Label label9;
	//}}
}

END JAVA PROGRAM
-- 
Tim Schaefer                         \\|//                                      
[email-masked]              (6 6)               Orlando, FL, USA, Earth
-------------------------------oOOo---( )---o00o--------------------------------
 WWW: http://www.mindspring.com/~tschaefe           Liberty: http://www.lp.org           
                        Informix FAQ: http://www.iiug.org            
--------------------------------------------------------------------------------