dbaccess faster than ESQL/C ?
Posted in 1997
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Server Administration, Platform-Specific Issues
Hi all,
I am using a SLIP connection to run a query using ESQL/C and dbaccess.
Both client and server are HP9000/7xx machines using HP-UX 9.05 and ppl
to establish the IP connection. I am running Informix ESQL/C 7.10 UD1 on
the client and a SE of the same version on the server.
When I am running a simple select query returning 74 hits 6 Bytes each
on the informix demonstration database, it takes dbaccess 2-3 seconds to
put the result to a file. Using a simple ESQL/C program the same query
takes 15 seconds only to read the data.
Analysing the ppl-logfiles showed that the query using dbaccess
transmitted 26 IP-packets while ESQL/C needed 90 IP-packets.
I tried to increase the size of the Fetchbuffer, but it showed no
result.
TIA for your help
Robert
--------------------------------------------------------------------
Here is the sourcecode:
dbaccess:
select stock_num, unit
from stock;
ESQL/C:
#include <time.h>
EXEC SQL INCLUDE sqlca;
int getDataFromStores()
{
int anz_rows=0;
int fehler=0;
EXEC SQL BEGIN DECLARE SECTION;
char statement[512];
char s_unit[8];
short s_num;
EXEC SQL END DECLARE SECTION;
sprintf(statement, "select stock_num, unit from stock");
EXEC SQL prepare s5 from :statement;
EXEC SQL declare s_cur5 cursor with hold for s5;
EXEC SQL open s_cur5;
for(;;)
{
EXEC SQL fetch s_cur5 into :s_num, :s_unit;
if(SQLSTATE[0]!='0' || SQLSTATE[1]!='0')
{
if(strncmp(SQLSTATE, "02", 2)!=0 || anz_rows==0)
fehler=-1;
break;
}
anz_rows++;
}
EXEC SQL close s_cur5;
EXEC SQL free s_cur5;
EXEC SQL free s5;
if (fehler==-1)
return(0);
else
return(anz_rows);
}
int main()
{
int liste;
time_t start, ende;
FetBufSize=10000;
EXEC SQL CONNECT TO "stores7";
start=time(NULL);
liste = getDataFromStores();
ende=time(NULL);
printf("%d rows read in %d seconds\\n", liste, ende-start);
EXEC SQL DISCONNECT ALL;
return 1;
}