Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] common area

From: Michael Meskes <meskes(at)topsystem(dot)de>
To: vadim(at)sable(dot)krasnoyarsk(dot)su (Vadim B(dot) Mikheev)
Cc: pgsql-hackers(at)postgresql(dot)org (PostgreSQL Hacker)
Subject: Re: [HACKERS] common area
Date: 1998-02-27 11:13:29
Message-ID: 199802271113.MAA13491@gauss.topsystem.de (view raw or flat)
Thread:
Lists: pgsql-hackers
Vadim B. Mikheev writes:
> Tables, queries ?

It's just a very simple test program I use mainly to debug ecpg. I include
it below.

> Also, did you look @ src/test/performance ?
> It would be nice to add support for Oracle there and new tests.

Yes, that's what I'm going to do once I have ecpg completed for 6.3. I'd
like to run some of mysql benchmarks too. In particular I'd like to see a
comparison between as many DB systems as possible using e.g. the Wisconsin
benchmark.

Michael

#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>

exec sql include sqlca;

exec sql whenever sqlerror sqlprint;
exec sql whenever not found sqlprint;

static void
print_result(long sec, long usec, char *text)
{
	if (usec < 0)
	{
		sec--;
		usec+=1000000;
	}
	printf("I needed %ld seconds and %ld microseconds for the %s test.\n", sec, usec, text);
}

int
main ()
{
exec sql begin declare section;
	long i;
exec sql end declare section;
	struct timeval tvs, tve;

	exec sql connect 'mm';

	exec sql create table perftest1(number int4, ascii char16);

	exec sql create unique index number1 on perftest1(number);

	exec sql create table perftest2(number int4, next_number int4);

	exec sql create unique index number2 on perftest2(number);

	gettimeofday(&tvs, NULL);

	for (i = 0;i < 1407; i++)
	{
		exec sql begin declare section;
			char text[16];
		exec sql end declare section;

		sprintf(text, "%ld", i);
		exec sql insert into perftest1(number, ascii) values (:i, :text);
		exec sql insert into perftest2(number, next_number) values (:i, :i+1);

		exec sql commit;
	}

	gettimeofday(&tve, NULL);

	print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "insert");

	gettimeofday(&tvs, NULL);

	for (i = 0;i < 1407; i++)
	{
		exec sql begin declare section;
			char text[16];
		exec sql end declare section;

		exec sql select ascii into :text from perftest1 where number = :i;

		exec sql commit;
	}

	gettimeofday(&tve, NULL);

	print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "selection&projection");

	gettimeofday(&tvs, NULL);

	for (i = 0;i < 1407; i++)
	{
		exec sql begin declare section;
			char text[16];
		exec sql end declare section;

		exec sql select perftest1.ascii into :text from perftest1, perftest2 where perftest1.number = perftest2.number and perftest2.number = :i;

		exec sql commit;
	}

	gettimeofday(&tve, NULL);

	print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "join");

	gettimeofday(&tvs, NULL);

	exec sql update perftest2 set next_number = next_number + 1;

	exec sql commit;

	gettimeofday(&tve, NULL);

	print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "update");

	exec sql drop index number2;

	exec sql drop table perftest2;

	exec sql drop index number1;

	exec sql drop table perftest1;

	exec sql commit;

	return (0);
}


-- 
Dr. Michael Meskes, Project-Manager    | topsystem Systemhaus GmbH
meskes(at)topsystem(dot)de                    | Europark A2, Adenauerstr. 20
meskes(at)debian(dot)org                      | 52146 Wuerselen
Go SF49ers! Go Rhein Fire!             | Tel: (+49) 2405/4670-44
Use Debian GNU/Linux!                  | Fax: (+49) 2405/4670-10

In response to

pgsql-hackers by date

Next:From: D'Arcy J.M. CainDate: 1998-02-27 12:54:32
Subject: Re: [HACKERS] INT2OID, etc.
Previous:From: Vadim B. MikheevDate: 1998-02-27 11:05:19
Subject: Re: [HACKERS] common area

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group